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
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”


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}

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


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

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


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s