Pages

Thursday, 13 February 2014

route and route table

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.95.0     *               255.255.255.0   U     1      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         172.16.95.1     0.0.0.0         UG    0      0        0 eth0


The server is sitting on the subnet 172.16.95.0. Add a route to the route table. The route will be rolled back next reboot. 

The gw has to be the ip directly reachable from your subset.
[root@localhost ~]# route add -net 192.168.102.0 netmask 255.255.255.0 gw 172.16.95.2


[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.102.0   172.16.95.2     255.255.255.0   UG    0      0        0 eth0
172.16.95.0     *               255.255.255.0   U     1      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         172.16.95.1     0.0.0.0         UG    0      0        0 eth0

[root@localhost ~]# route del -net 192.168.102.0 netmask 255.255.255.0 eth0
[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.95.0     *               255.255.255.0   U     1      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         172.16.95.1     0.0.0.0         UG    0      0        0 eth0


Add the route permanently, network restart is needed.
[root@localhost ~]# echo "192.168.102.0/24 via 172.16.95.2" >> /etc/sysconfig/ne
twork-scripts/route-eth0

[root@localhost ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.102.0   172.16.95.2     255.255.255.0   UG    0      0        0 eth0
172.16.95.0     *               255.255.255.0   U     1      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         172.16.95.1     0.0.0.0         UG    0      0        0 eth0

No comments:

Post a Comment