I want to add the following route command route add -net 192.168.2.0/27 gw 192.168.2.3
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
Kai Schaetzl wrote:
I want to add the following route command route add -net 192.168.2.0/27 gw 192.168.2.3
try
any net 192.168.2.0 netmask 255.255.255.224 gw 192.168.2.3
in your /etc/sysconfig/static-routes file
Though I'm not sure why you'd want to have a static route that points to a local interface, just set the subnet of the interface to 255.255.255.224 and you don't need a static route.
I use that syntax and it works fine..
nate
Nate wrote on Tue, 28 Apr 2009 12:21:48 -0700 (PDT):
any net 192.168.2.0 netmask 255.255.255.224 gw 192.168.2.3
in your /etc/sysconfig/static-routes file
yes, this works, thanks! I have found a better method without adding a route in the meantime, but I wanted to know about this, just in case.
Though I'm not sure why you'd want to have a static route that points to a local interface, just set the subnet of the interface to 255.255.255.224 and you don't need a static route.
That actually does not work. The net is set, of course, I think you would get an error if not. The case is a bit complicated. I want to reach a domU from another machine thru a crossover link and not via the switched network. For that purpose I added a private subnet to all involved NICs and to the domU. That works in one direction but not in the other direction. It also doesn't work from the dom0 itself. When I add this route it all works. Another solution is to use another private subnet for the third NIC in the machine. Originally, NIC2 and NIC3 had both an IP number from the same private subnet and NIC3 seems to have catched all the packets. And the whole thing was only necessary because of this: SUBJECT:[CentOS] eth0 killed when adding virtual interface and multipleNICs are present
I use that syntax and it works fine..
Indeed, but it's not in the manual :-( I had read about it in a few postings, but it seemed to be obsoleted. I think the route-interface syntax does not work because it all involves an interface. The route add and the static-routes don't specify an interface.
Kai
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
Robert Moskowitz wrote on Tue, 28 Apr 2009 15:25:00 -0400:
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
eth0 does not have an IP no., it is a bridge. xenbr1 has the IP. Now look back in my mail :-) I used your exact syntax, but for route-xenbr.
Just to make sure I used route-eth0 and it's not even carried out. Which makes sense, it's not an inet device.
Kai