Red Hat Linux Static Routing Configuration

by on August 17, 2008 · 9 comments· LAST UPDATED August 17, 2008

in , ,

Q. I've two network interface connected to two different routers as follows:
[a] eth0 LAN network 10.0.0.0/8 - gateway IP - 10.8.2.65

[b] eth1 ISP assigned network 202.54.22.128/28 - gateway IP - 202.54.22.129

I can only ping to public server but not to another servers inside LAN? I'm not able to route traffic via 10.8.2.65. How do I configure static routing under Red Hat Enterprise Linux 5.x or CentOS Linux 5.2?

A. Under Red Hat you need to define static routing using route command. The configuration is stored under /etc/sysconfig/network-scripts/route-eth0 for eth0 interface.

Update route using route command

Type the following command:
# route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.8.2.65 eth0
# route -n

Create static routing file

The drawback of abive 'route' command is that, when RHEL reboots it will forget static routes. So store them in configuration file:
echo '10.0.0.0/8 via 10.8.2.65' >> /etc/sysconfig/network-scripts/route-eth0
Restart networking:
# service network restart
Verify new changes:
# route -n
# ping 10.8.2.65
# ping 10.8.2.10
# ping google.com
# traceroute google.com
# traceroute 10.8.2.10

Further readings:

  • man pages ip, route command
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 9 comments… read them below or add one }

1 kangsirodj November 8, 2008 at 6:33 am

please tell me, what for this command ? I am using centos 4 :
echo 1 > /proc/sys/net/ipv4/ip_forwarding

is it any relations with static routing ?

thank you

Reply

2 nixCraft November 8, 2008 at 6:37 am

It will turn on routing on Linux i.e. it will set Linux a router device.

Reply

3 vinay January 24, 2009 at 2:59 pm

How to cinfigure ADSL modem connection on linux

Reply

4 Srinivas D April 7, 2009 at 10:31 am

Thanks a ton, the static route commands provided are very helpful. More over they are friendly to update my knowledge.

Reply

5 Arshad January 8, 2010 at 6:00 am

please inform me about the ststic routing between lans

Reply

6 Sagar Shivnani September 26, 2011 at 12:35 pm

Very helpful :)

Reply

7 StoneCut April 19, 2012 at 7:23 am

Hi, maybe you can help with my routing issue. We have a SLES Squid server with following IP configuration:
eth0: 10.0.20.110 / 24
-> eth0 also has a second IP address 10.0.20.111 / 24
eth1: 10.0.18.111 / 24

Squid is listening on both 10.0.20.x addresses. We cannot change these, unfortunately.

So far we have been using 10.0.20.1 as default gateway but we’d like to switch to 10.0.18.1 instead. However we tried setting 10.0.18.1 as default gateway and then added a route “10.0.0.0/8 -> 10.0.20.1″. This way we want to direct ALL traffic to the new gateway.

Problem: Squid works fine for all clients EXCEPT those that are in the 10.0.18.x subnet – no webpage loads.

Can anyone help ?

Reply

8 G-Man June 6, 2012 at 4:09 am

Hi

I have two Service that support the identical informix Database.
the Applcation Authinecates ssh on eth0 but replicates on eth1.
the ip addresses are set to the same subnet on serv1 and server2 Example
Server 1
eth0 IP 192.123.4.205
eth1 IP 192.123.4.206
Submsk 255.255.255.0h0
Gatway 192.123.4.1

Server 2
eth0 IP 192.143.80.205
eth1 ip 192.143.80.206
Submsk 255.255.255.0
Gateway 192.143.80.1

the problem is every thing run in and out of eth0. the database replcation fails
how can I setup a static route from eth0 to eth0 and eth1 to eth1 Example:
Svr1 th0/192.123.4.205 to route to Svr2 eth0/192.143.80.205
and
Srv1 eth1/192.123.4.206 to Srv2 eth1/ 192.143.80.206
via the gateway Srv1/192.123.4.1 and Srv2/192.143.80.1
can this be done?

Reply

9 Bhageerathan July 20, 2012 at 1:45 pm

I have configured ipvsadm on 172.17.0.0/16 segment

LB IP 172.17.0.100
real servers are 172.17.0.101 and 172.17.0.102
port 80

I can able to browse my website through other segments. but am not able to browse using LB in inside this same network 172.17.0.0/16. i can browse if i use real server IP directly inside this segment….
Any solution please…..

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , ,

Previous Faq:

Next Faq: