8i | 9i | 10g | 11g | 12c | Misc | PL/SQL | SQL | RAC | Linux

Home » Articles » Linux » Here

Routing IP Traffic on Linux

Most of the time routing will be done by your network hardware, but it can be done using Linux.

This article provides an introduction to routing IP traffic on Linux, with specific reference to the information needed for the RHCE EX300 certification exam.

Remember, the exams are hands-on, so it doesn't matter which method you use to achieve the result, so long as the end product is correct.

Related articles.

Route IP Traffic

Routes are dynamically managed using the route or ip route commands.

A default routes can be managed as follows.

# route del default gw
# route add default gw

# ip route del default via
# ip route add default via

Specific routes can be added, with or without a default gateway setting, using the following commands.

# route add -net netmask dev eth0
# route add -net netmask gw dev eth0

# ip route add dev eth0
# ip route add via dev eth0

Route information is be displayed as follows.

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 eth0
link-local      *          U     1002   0        0 eth0     *        U     0      0        0 eth0     *        U     0      0        0 eth0   UG    0      0        0 eth0     *        U     0      0        0 eth0   UG    0      0        0 eth0

# ip route
default via dev eth0  proto static dev eth0  scope link  metric 1002 dev eth0  scope link dev eth0  scope link via dev eth0 dev eth0  proto kernel  scope link  src via dev eth0

Routes are removed using the following commands.

# route del -net netmask dev eth0
# route del -net netmask gw dev eth0

# ip route del via dev eth0
# ip route del dev eth0

Create Permanent Static Routes

The static routes configured in the previous section are all transient, in that they are lost on reboot. To configure a permanent static route for an interface, create a file with the following format "/etc/sysconfig/network-scripts/route-<INTERFACE>". For example, we could create the "/etc/sysconfig/network-scripts/route-eth0" file with the following entries. via dev eth0 via dev eth0

We can then stop and start the interface as follows.

# cd /etc/sysconfig/network-scripts/
# ifdown eth0
# ifup eth0

In addition, the default gateway can be specified globally in the "/etc/sysconfig/network" file, for the interface in the "/etc/sysconfig/network-scripts/ifcfg-<INTERFACE>".

For more information see:

Hope this helps. Regards Tim...

Back to the Top.