add static route in Cantos and make sure it wont loose after reboot
1. Adding Routes
[root@localhost ~]# route add -net 10.4.3.0 netmask 255.255.255.0 gw 192.168.129.55
[root@localhost ~]#
[root@localhost ~]#
Or
[root@localhost ~]# route add -net 10.4.2.0 netmask 255.255.255.0 dev eth0
[root@localhost ~]#
[root@localhost ~]#
2. Show routing table
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
10.4.3.0 192.168.129.55 255.255.255.0 UG 0 0 0 eth0
10.4.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.129.2 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.129.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
10.4.3.0 192.168.129.55 255.255.255.0 UG 0 0 0 eth0
10.4.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.129.2 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
if you dont wanna loose, you can add above command to /etc.rc.local
or try this way
add routes in route-eth0 file
static routes for the eth0 interface would be stored in the
/etc/sysconfig/network-scripts/route-eth0
file. The route-interface
file has two formats: IP command arguments and network/netmask directives.The following is a sample route-eth0
file using the IP command arguments format. The default gateway is 192.168.0.1, interface eth0. The two static routes are for the 10.10.10.0/24 and 172.16.1.0/24 networks:
default 192.168.0.1 dev eth0 10.10.10.0/24 via 192.168.0.1 dev eth0 172.16.1.0/24 via 192.168.0.1 dev eth0
Static routes should only be configured for other subnets. The above example is not necessary, since packets going to the 10.10.10.0/24 and 172.16.1.0/24 networks will use the default gateway anyway. Below is an example of setting static routes to a different subnet, on a machine in a 192.168.0.0/24 subnet. The example machine has an eth0 interface in the 192.168.0.0/24 subnet, and an eth1 interface (10.10.10.1) in the 10.10.10.0/24 subnet: