Redhat – IP and Route Settings
Written by vaheeD on December 29, 2012
Permanent IP Settings
Primary: /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static BROADCAST=172.16.10.63 IPADDR=172.16.10.33 NETMASK=255.255.255.224 NETWORK=172.16.10.32 ONBOOT=yes
Secondary: /etc/sysconfig/network-scripts/ifcfg-eth0:0
BROADCAST=192.168.0.255 IPADDR=192.168.0.1 NETMASK=255.255.255.0 NETWORK=192.168.0.0
Secondary: /etc/sysconfig/network-scripts/ifcfg-eth0:1
BROADCAST=172.16.10.127 IPADDR=172.16.10.100 NETMASK=255.255.255.224 NETWORK=172.16.10.96
Gateway: /etc/sysconfig/network
NETWORKING=yes HOSTNAME=RedhatBox GATEWAY=172.16.10.1
DNS: /etc/resolv.conf
nameserver 192.9.9.3
Temporary IP settings
Primary
# ifconfig eth0 192.168.1.4 netmask 255.255.255.0 broadcast 192.168.1.255
Secondary
# ifconfig eth0:0 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255
List main route table
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.240 U 0 0 0 br0 192.168.0.16 0.0.0.0 255.255.255.240 U 0 0 0 br0 192.168.0.32 0.0.0.0 255.255.255.224 U 0 0 0 br0 192.168.0.64 0.0.0.0 255.255.255.192 U 0 0 0 br0 192.168.0.192 192.168.0.60 255.255.255.192 UG 0 0 0 br0 192.168.0.128 0.0.0.0 255.255.255.192 U 0 0 0 br0 10.10.10.128 0.0.0.0 255.255.255.192 U 0 0 0 br0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 br0
Add/Delete Routes Temporary
# route add -host 10.10.10.129 dev eth1 # route add -net 10.10.10.128/26 dev eth0 # route add -net 172.16.10.1/24 gw 10.10.10.130 # route del -net 192.168.1.0/24 dev eth1 # route del default # route add default gw 10.10.10.129 dev eth1