User Tools

Site Tools


linux:network_config

Change IP adress on Suse using command line

ip a s 
ip r s
ip n s

/etc/sysconfig/network/ifcfg-eth0

Samples of proxy variables:

export http_proxy=http://10.203.0.1:5187/
export https_proxy=http://10.203.0.1:5187/
export ftp_proxy=http://10.203.0.1:5187/
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
http_proxy=http://username:password@hostname:port

Remove virbr0 on Redhat

The virbr0 (bridge) is like a switch into which you can connect your virtual guests and your host. The host can act as a router between outside physical subnet and internal virtual subnet. The router can do NAT (aka masquerade).

Disable libvirtd default network

# systemctl stop libvirtd.service
# systemctl disable libvirtd.service
# virsh net-destroy default
# virsh net-autostart default --disable

Disable permanent

# virsh net-undefine default

Or use

# brctl show
bridge name     bridge id                        STP enabled     interfaces
virbr0              8000.000000000000         no
# ip link set virbr0 down
# brctl delbr virbr0

Disable IPv6 on Redhat

[root@Centos64 ~]# vi /etc/modprobe.d/disable-ipv6.conf
install ipv6 /bin/true
[root@Centos64 ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Centos64
GATEWAY=192.168.0.1
[root@Centos64 ~]# echo “net.ipv6.conf.all.disable_ipv6 = 1″ >> /etc/sysctl.conf

Add static routes permanent

/etc/sysconfig/network

default via 192.168.1.1 dev eth0
10.10.10.0/24 via 192.168.1.1 dev eth1
10.10.11.0/24 via 192.168.11.1

/etc/sysconfig/network-scripts/route-eth0

default via 192.168.0.1 dev eth0
10.10.10.0/24 via 192.168.0.10 dev eth0
172.16.1.10/32 via 192.168.0.10 dev eth0

Add static routes nonpersistent

To add or delete a route from the table, use the ip route add or ip route del commands. For example, to replace the entry for the static default route:

# ip route del default
# ip route show
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15 
# ip ro add default via 10.0.2.1 dev eth0 proto static
# ip route show
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15  
default via 10.0.2.1 dev eth0  proto static 

To add a route to the network 10.0.3.0/24 via 10.0.3.1 over interface eth1, and then delete that route:

# ip route add 10.0.4.0/24 via 10.0.2.1 dev eth1
# ip route show
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15 
10.0.3.0/24 via 10.0.3.1 dev eth1
default via 10.0.2.2 dev eth0  proto static 
# ip route del 10.0.3.0/24
# ip route show
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15 
default via 10.0.2.2 dev eth0  proto static 

The ip route get command is a useful feature that allows you to query the route on which the system will send packets to reach a specified IP address, for example:

# ip route get 23.6.118.140
23.6.118.140 via 10.0.2.2 dev eth0  src 10.0.2.15 
    cache  mtu 1500 advmss 1460 hoplimit 64

Rename a network device to eth0

Edit kernel boot parameter.

Edit file /etc/default/grub and add net.ifnames=0 biosdevname=0 to line GRUB_CMDLINE_LINUX, for instance:

GRUB_CMDLINE_LINUX=" crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet"

Regenerate a GRUB configuration file and overwrite existing one:

# grub2-mkconfig -o /boot/grub2/grub.cfg

Update the rules file:

# vi /etc/udev/rules.d/70-persistent-net.rules :
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="12:91:0C:F9:B7:98", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# cd /etc/sysconfig/network-scripts/
# mv ifcfg-ens192 ifcfg-eth0
# vi ifcfg-eth0
DEVICE=eth0        ### Change it to new device name "eth0"
linux/network_config.txt · Last modified: 2021/01/01 21:25 (external edit)