How to Configure Static Routes on CentOS 6.2

Share this Article :

Routing is the process of selecting paths in a network along which to send network traffic. It’s not necessary to configure Static Routes on Red Hat Enterprise Linux servers or CentOS servers since routing will be configured on routing devices such as routers, bridges, gateways, firewalls and switches. However, if static routes are required they can be configured for each interface. This can be useful when you have multiple network interfaces in different subnets such as eth0, eth1 and eth2. The following static route commands has been tested on Linux CentOS 6.2 server.

Display routing table using the following command :

[[email protected] ~]# netstat -rn

This command will add the Static Routes on CentOS 6.2 server. For example network 192.168.2.0/24 available via 192.168.2.1 on device eth1 :

[[email protected] ~]# ip route add 192.168.2.0/24 via 192.168.2.1 dev eth1

Alternatively, you can use this command :

[[email protected] ~]# route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 dev eth1

Note : The drawback of using these two commands is it will forget the static routes when server rebooted.

Leave a Reply