How to Configure Static Routes on CentOS 6.2

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.

See also  How to Add Static Routes in CentOS 5.6

Display routing table using the following command :

[root@centos62 ~]# 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 :

[root@centos62 ~]# ip route add 192.168.2.0/24 via 192.168.2.1 dev eth1

Alternatively, you can use this command :

[root@centos62 ~]# 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *