/etc/sysconfig/network-scripts/route-ethN Question

RILINDO FOSTER rilindo at me.com
Tue Jun 7 18:23:34 UTC 2011


Another way is to dispense with the routing syntax and setup the variables in the file:


[root at XXX network-scripts]# cat route-eth0 
ADDRESS0=192.168.16.0
ADDRESS1=192.168.17.0
ADDRESS2=192.168.18.0
NETMASK0=255.255.255.0
NETMASK1=255.255.255.0
NETMASK2=255.255.255.0
GATEWAY0=192.168.15.200
GATEWAY1=192.168.15.200
GATEWAY2=192.168.15.200

Red Hat's startup scripts will pattern match base on the variables and file name, setting the routes accordingly per adapter. In this case, the routes in question will be configured through eth0. 

Here is another example:

[root at sl6 network-scripts]# cat route-virbr0 
ADDRESS0=192.168.122.0
NETMASK0=255.255.255.0

This setup the routes on the virtual interface to my VMs. Since the gateway is local, there was no need to setup the gateway variable.

At any event, here is the output of my routes after bootup:

[root at sl6 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.18.0    192.168.15.200  255.255.255.0   UG        0 0          0 eth0
192.168.17.0    192.168.15.200  255.255.255.0   UG        0 0          0 eth0
192.168.16.0    192.168.15.200  255.255.255.0   UG        0 0          0 eth0
192.168.15.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         192.168.15.1    0.0.0.0         UG        0 0          0 eth0

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


On Jun 7, 2011, at 1:17 PM, Richardson, Joshua A. wrote:

> You can simply create the file in the /etc/sysconfig/network-scripts folder.  Here's an example of one I use:
> 
> [root at AMDRFileServer1 ~]# cat /etc/sysconfig/network-scripts/route-eth0
> # /etc/sysconfig/network-scripts/route-eth0
> #
> 0.0.0.0/0 via 10.10.207.1 dev eth0  # Default gateway route
> 192.168.4.3 via 10.10.207.88 dev eth0 # Host route
> 192.168.0.0/16 dev eth0 # Subnet route
> 
> 
> Josh Richardson
> General Dynamics AIS
> Office: 703-272-1761
> Cell: 540-383-9093
> 
> -----Original Message-----
> From: redhat-list-bounces at redhat.com [mailto:redhat-list-bounces at redhat.com] On Behalf Of Matty Sarro
> Sent: Tuesday, June 07, 2011 9:02 AM
> To: General Red Hat Linux discussion list
> Subject: /etc/sysconfig/network-scripts/route-ethN Question
> 
> Hey everyone,
> I am trying to find out more about setting up per-device routing using
> the /etc/sysconfig/network-scripts/route-ethN file. Basically I'm not
> about to find any real details about how the file is supposed to be
> created. Is it just a shell script with ip route commands? I have
> three network interfaces, and each needs to be connected to its own
> discrete network with its own gateway. Right now I have all of the
> rules set up in /etc/rc.local, which seems to work fine for the first
> two interfaces, but not the third.
> 
> Due to the circumstances, normal static routing won't work - I need to
> use iproute2.
> 
> Since the /etc/sysconfig/network-script/route-ethN file gets run when
> the interface comes up, I am assuming this may help. Any advice is
> appreciated.
> 
> -- 
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 
> -- 
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list




More information about the redhat-list mailing list