Temporary Route:
First add temporary route on the server & note down the configuration that is shown on the server using below command
ip route add 172.22.126.18 via 172.22.97.4 dev eth0 | ||
ip route add 172.22.126.19 via 172.22.97.4 dev eth0 Once you add the route using above commands check the output of route -n command.It will give you an idea regarding default netmask |
[root@connector ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.22.127.249 172.22.124.7 255.255.255.255 UGH 0 0 0 eth0
172.22.124.0 0.0.0.0 255.255.254.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 172.22.124.1 0.0.0.0 UG 0 0 0 eth0
Now after service restart the routing configurations taken by above command will be removed.
but if you want to add static routes you can follow below steps
Static Route:
I have created route-eth0 file & made the below changes & can confirm that static routes have been added.
The below configuration is persistent after service network restart
1.cd /etc/sysconfig/network-scripts | |||
2.vi route-eth0 | |||
append the below lines
ADDRESS0=172.22.126.18
NETMASK0=255.255.255.255
GATEWAY0=172.22.97.4
ADDRESS1=172.22.126.19
NETMASK1=255.255.255.255
GATEWAY1=172.22.97.4
| |||
3.Service network restart | |||
The below configuration is persistent after service network restart |
[root@connector network-scripts]# cat route-eth0
ADDRESS0=172.22.126.18
NETMASK0=255.255.255.255
GATEWAY0=172.22.97.4
ADDRESS1=172.22.126.19
NETMASK1=255.255.255.255
GATEWAY1=172.22.97.4
[root@connector network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.22.126.18 172.22.97.1 255.255.255.255 UGH 0 0 0 eth0
172.22.126.19 172.22.97.1 255.255.255.255 UGH 0 0 0 eth0
192.168.38.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
192.168.36.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.37.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
172.22.97.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1005 0 0 eth3
0.0.0.0 172.22.97.1 0.0.0.0 UG 0 0 0 eth0
#ip route add 172.22.126.18 via 172.22.97.4 dev eth0 | |||
#ip route add 172.22.126.19 via 172.22.97.4 dev eth0 |