1. Adding Routes
[root@localhost ~]#
Or
[root@localhost ~]#
2. Show routing table
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 ~]#
/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: