Three Ways to Configure Persistent Static Routes on Linux CentOS

centos6There are several different ways to configure persistent static routes on Linux CentOS. By using Static routes, we can improves overall performance of the network and static routing is achieved by manually adding routes to the routing table. Static route can be added and delete using “route” command. But it will forget the static routes configuration when server rebooted. This will lead to the network interruption. Follow one of these three options to configure static route on CentOS.

1. Edit the file /etc/sysconfig/network-scripts/route- and then add the following lines :

[root@centos63 ~]# vi /etc/sysconfig/network-scripts/route-eth0

GATEWAY0=<gateway address>
NETMASK0=<network netmask>
ADDRESS0=<network address>
GATEWAY1=<gateway address>
NETMASK1=<network netmask>
ADDRESS1=<network address>

Examples :

GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=192.168.1.54
GATEWAY1=192.168.2.1
NETMASK1=255.255.255.0
ADDRESS1=192.168.2.54

2. Edit the file /etc/sysconfig/network-scripts/route- and then add the following lines :

192.168.1.0/24 via 192.168.1.1 dev eth0
192.168.2.0/24 via 192.168.2.1 dev eth0

3. Edit the file /etc/sysconfig/static-routes as below :

any -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
any -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

How to Check Routing Tables on Fedora 16

In Linux operating system, routing table is used by the computer networks or servers to stores the routes of the destinations that responsible for forwarding. Routing tables contain a list of IP addresses and each of IP addresses identifies a network gateway. In this post, i will show you three ways to check and display the linux Routing Table on Fedora 16 server.

By using Route Command :
Route manipulates the kernel’s IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured.

By using netstat command :
Netstat prints information about the Linux networking subsystem such as network connections, routing tables and interface statistics.

1. Display routing table using “route -n” :

[root@fedora16 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 p3p1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 p3p1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 p3p1

2. Display routing table using “netstat -rn” :

[root@fedora16 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 p3p1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 p3p1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 p3p1

3. Display routing table using “ip route show” :

[root@fedora16 ~]# ip route show
default via 192.168.1.1 dev p3p1
169.254.0.0/16 dev p3p1  scope link  metric 1002
192.168.1.0/24 dev p3p1  proto kernel  scope link  src 192.168.1.47

How to Check Routing Table on Linux CentOS 6.2

In Linux operating system, routing table is used by the computer networks or servers to stores the routes of the destinations that responsible for forwarding. Routing tables contain a list of IP addresses and each of IP addresses identifies a network gateway. In this post, i will show you three ways to check and display the linux Routing Table. This command has been tested on CentOS 6.2 server.

1. Display routing table using “netstat -rn” :

[root@centos62 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.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         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

2. Display routing table using “ip route show” :

[root@centos62 ~]# ip route show
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.44
169.254.0.0/16 dev eth0  scope link  metric 1002
default via 192.168.1.1 dev eth0

3. Display routing table using “route -n” :

[root@centos62 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.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
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0