[CentOS] adding static route via network setup fails

Robert Moskowitz rgm at htt-consult.com
Tue Apr 28 20:25:00 UTC 2009


Kai Schaetzl wrote:
> I want to add the following route command
> route add -net 192.168.2.0/27 gw 192.168.2.3
>   

Assume 192.168.2.3 is reachable via eth0 (eg eth0's IP is 192.168.2.2).  
Make the file /etc/sysconfig/network-scripts/route-eth0:

NETMASK0=255.255.255.224
ADDRESS0=192.168.2.0
GATEWAY0=192.168.2.3

This is all explained in

/usr/share/doc/initscripts-8.45.19.EL/sysconfig.txt (or whatever the 
current  version is.)

> via the normal network setup.
> The result should be the following routing table (the first line):
> 192.168.2.0/27 via 192.168.2.3 dev xenbr1  scope link
> 192.168.2.0/27 dev eth2  proto kernel  scope link  src 192.168.2.4
> 192.168.2.0/27 dev xenbr1  proto kernel  scope link  src 192.168.2.3
> 192.168.1.0/24 dev xenbr0  proto kernel  scope link  src 192.168.1.24
> default via 192.168.1.1 dev xenbr0
>
> I found:
> http://www.cyberciti.biz/faq/redhat-centos-fedora-linux-static-routing/
> http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-networkscripts-
> static-routes.html
>
> tells me to use sysconfig/route-xenbr1
>
> But whatever syntax I try I get a variety of errors:
>
> Bringing up interface xenbr1:  Error: an inet address is expected rather 
> than "1"..168.2.3
> Bringing up interface xenbr1:  Error: an inet prefix is expected rather 
> than "19/27"..2.0
> Bringing up interface xenbr1:  Error: either "to" is duplicate, or 
> "192.168.2.3" is a garbage.
> "ringing up interface xenbr1:  Cannot find device "xenbr1
>
> route-xenbr1:
> #192.168.2.0/27 via 192.168.2.3
>
> #GATEWAY0=192.168.2.3
> #NETMASK0=255.255.255.224
> #ADDRESS0=192.168.2.10
>
> #default 192.168.2.3 dev xenbr1
>
> 192.168.2.0/27 via 192.168.2.3 dev xenbr1
>
> (the commented out are from various tries, corresponding to the errors 
> above)
>
> This is on a xen kernel. 2.6.18-128.1.6.el5xen
>
> Kai
>
>   


More information about the CentOS mailing list