Adding Host routes with CentOS?


On debian / ubuntu I use the below settings for a classless routed xen setup –
I need to route for my vm’s to be reachable in the additional subnets I was assigned at Hetzner and I want to avoid wasting 2 ip’s per subnet for routing on the same xen box…

auto eth0
iface eth0 inet static
address domU
gateway dom0
netmask 255.255.255.255
pointopoint dom0
post-up ethtool -K eth0 tx off

It’s not intuitive and the pointopoint is not a typo but the idea of someone how though this would be “funny”. But it works!

On CentOS things are very much different:

Defining a default- GATEWAY in /etc/sysconfig/network will not work without the host route.
Defining a host route (or the gateway) will not work either:

I tried this route setup using a new file in /etc/sysconfig/network-scripts named “route-eth0”

ADDRESS0=dom0ip
GATEWAY0=eth0
NETMASK0=255.255.255.255

This won’t work as the script doesn’t support host routes over a link local at all?
There is some plip support but I don’t know how that’s gonna work!

After some more gray hair, In the main ifup-post script i found it will load site local extensions:

if [ -x /sbin/ifup-local ]; then
/sbin/ifup-local ${DEVICE}
fi

So I created a script called /sbin/ifup-local with the following content:

#!/bin/bash

if [ $1 = “eth0” ]
then
echo “applying fixup for default routes”
route add -host dom0ip eth0
route add default gw dom0ip
fi

At least this little hack now really works.
I’m not sure saving two public IP’s was worth this hassle though.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s