Recent Changes - Search:


Code:


Social:


My journals will take the place of a blog. If you go to the Journal page there is an RSS feed to subscribe with.

(:blogcal group=Journal:)


Sites I take responsibility for

West Volusia, Florida

Documents

Technical

General

Me

Living

Places I frequent

Hobbies

Humor

Items for sale:


Clipboard

edit SideBar

Static routing in Redhat Linux

Include our styles below Infobox - invoke as >>infobox<< ... >><<

Codebox: - invoke as >>codebox<< ... >><<

warnbox: - invoke as >>codebox<< ... >><<

editingbox: - invoke as >>codebox<< ... >><<

noticebox: - invoke as >>codebox<< ... >><<

Page bread crumbs: Main - MyPublicTechnicalNotes - SoftwareAndOperatingSystems - Linux - Redhat - All - Network - Routing

Pages by tags: (:listtags:)
Subscribe to this wiki: RSS Feed RSS or subscribe to this page for changes: RSS Feed RSS
496 articles have been published so far. Recent changes
(:addThis btn="custom":)

2016-03-22: This site is being moved to my main site at https://kevininscoe.com/wiki as part of a consolidation to one domain.


Notes:

http://www.cyberciti.biz/faq/howto-rhel-fedora-linux-setup-default-gateway/

http://linux.derkeiler.com/Mailing-Lists/RedHat/2006-05/msg00254.html

https://listman.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-networkscripts-static-routes.html

http://kbase.redhat.com/faq/docs/DOC-3099

http://www.akadia.com/services/redhat_static_routes.html

http://www.cementhorizon.com/wiki/index.php/Static_Persistent_Routes_under_Red_Hat_Enterprise_Linux_3_RHEL_3

Default gateway:

The default gateway is a function of the system as a whole and should be set in /etc/sysconfig/network

GATEWAY=10.1.2.3

Host (or interface routes):

How do I create persistent static routes in Red Hat Enterprise Linux?

 /etc/sysconfig/network-scripts/route-ethX

Every entry or a route has three lines as follows:

 GATEWAY<N>=xxx.xxx.xxx.xxx
 NETMASK<N>=yyy.yyy.yyy.yyy
 ADDRESS<N>=zzz.zzz.zzz.zzz

 GATEWAY1=10.83.12.3
 NETMASK1=255.255.255.0
 ADDRESS1=10.83.12.40

Overview

With the introduction of Redhat version 8 and continued into version 9, the /etc/sysconfig/static-routes file no longer seems to function correctly.

Linux static routes changed in 8.0 to a new format. Now you are to create a file in /etc/sysconfig/network-scripts for each Ethernet interface you wish to create static routes on.

Example:

 # touch /etc/sysconfig/network-scripts/route-eth0

The syntax for this file is different from the traditional route format used in /etc/sysconfig/static-routes . Redhat has yet to document the change on their web site as of June 2003.

Syntax based on a usenet post go to /etc/sysconfig/network-scripts, make a file called route-devicename (ex: route-eth0) and populate it with your static routes for that device so if you wanted to make a static route to the 192.168.0.0/24 network through 152.3.182.5 type:

    192.168.0.0/24 via 152.3.182.5

Persistent static routes for ANY linux distribution

You may use this method to add static routes and it will work under any Linux distribution. However, it is considered by some a 'hack' or the 'ugly way'.

    Edit your /etc/rc.local file and add your static routes using the route statement.

    Example:

    route add -net 10.10.98.0 netmask 255.255.255.0 gw 10.164.234.132 dev eth1
    route add -net 10.164.234.96 netmask 255.255.255.252 gw 10.164.234.132 dev eth1
    route add -net 10.164.234.112 netmask 255.255.255.240 gw 10.164.234.132 dev eth1

Force the old static-routes file to work under Redhat 9

Clear out the new /etc/sysconfig/network-scripts/ifup-routes script so that you can populate it with the original shell script from Redhat 7.x.

    cat /dev/null > /etc/sysconfig/network-scripts/ifup-routes
    vi /etc/sysconfig/network-scripts/ifup-routes

    type in the following (or copy and paste) not including the tilde lines:

    #!/bin/sh

    # adds static routes which go through device $1

    if [ "$1" = "" ]; then
      echo "usage: $0 <net-device>"
      exit 1
    fi

    if [ ! -f /etc/sysconfig/static-routes ]; then
      exit 0
    fi

    # note the trailing space in the grep gets rid of aliases
    grep "^$1 " /etc/sysconfig/static-routes | while read device args; do
      /sbin/route add -$args $device
    done
    grep "^any " /etc/sysconfig/static-routes | while read ignore type net netmask mask bogus dev ; do
      if [ "$dev" = "$1" ]; then
        /sbin/route add -$type $net $netmask $mask $dev
      fi
    done

Remember to use /etc/sysconfig/network for your default gateway

If you only intend to add one route, your default gateway, then you need not worry about the static routes file or using the route command. Simply add your default gateway in /etc/sysconfig/network.

Example:

    NETWORKING=yes
    HOSTNAME="hostname.linux.org"
    GATEWAY="10.164.234.1"
    GATEWAYDEV="eth0"
    FORWARD_IPV4="yes"

Kevin's Public Wiki maintained and created by Kevin P. Inscoe is licensed under a
Creative Commons Attribution 3.0 United States License.

Back to my web site - http://kevininscoe.com

Edit - History - Print - Recent Changes - Search
Page last modified on December 14, 2009, at 11:32 AM EST