Red Hat Linux Static Routing Configuration

Posted on in Categories , , , , , last updated August 17, 2008

Q. I’ve two network interface connected to two different routers as follows:
[a] eth0 LAN network – gateway IP –

[b] eth1 ISP assigned network – gateway IP –

I can only ping to public server but not to another servers inside LAN? I’m not able to route traffic via 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 netmask gw 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 ' via' >> /etc/sysconfig/network-scripts/route-eth0
Restart networking:
# service network restart
Verify new changes:
# route -n
# ping
# ping
# ping
# traceroute
# traceroute

Further readings:

  • man pages ip, route command

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

10 comment

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

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

    So far we have been using as default gateway but we’d like to switch to instead. However we tried setting as default gateway and then added a route “ ->”. 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 ?

  2. 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
    eth1 IP

    Server 2
    eth0 IP
    eth1 ip

    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/ to route to Svr2 eth0/
    Srv1 eth1/ to Srv2 eth1/
    via the gateway Srv1/ and Srv2/
    can this be done?

  3. I have configured ipvsadm on segment

    LB IP
    real servers are and
    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 i can browse if i use real server IP directly inside this segment….
    Any solution please…..

Leave a Comment