I have a KVM host (A) running a virtual machine (B). They each have their own external IP address and the networking is setup using bridging between eth0 and br0 on A. B uses eth0, with A being the gateway.

The problem is that the two external IP addresses are on different subnets (different /8s in fact) so by default, B claims it cannot reach A (Network Unreachable).

I can resolve this by adding a static route on B:
echo "any host gateway_ip dev eth0" > /etc/sysconfig/static-routes

Modifying /etc/init.d/networking to reload the gateway after applying static routes (I only added the final line before fi):

if [ -f /etc/sysconfig/static-routes ]; then  
    grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do  
        /sbin/route add -$args  
    route add default gw "${GATEWAY}"  

If I then restart networking, it comes online. How can I do this (or work around it some other way) prior to the system being installed, ideally inside an Anaconda kickstart file?


since you're running VMs, why not use templates and snapshots instead of kickstarting? Customizations can be put in the /etc/rc.d/sysinit file, under

# Configure machine if /.unconfigured exists:

then run sys-unconfig to prepare the VM to become a template.

After this is done, you can clone the images with qemu-img convert or take snapshots from the original image, to save disk space, and attach the cloned/snapshotted images to new VMs. They will all have the same configuration and files, minus the typical settings removed by sys-unconfig. And whatever else you add to rc.sysinit as well of course.

|improve this answer|||||
  • Thanks dyasny, I'll take a look over this when I've got a bit of time, it probably does enough for my needs. I'll leave the question open for a couple of days to see if I get a direct answer otherwise I'll always be wondering! – James L Mar 1 '11 at 14:44
  • @JimB there's a sys-unconfig and /etc/rc.d/rc.sysinit on FC14 and CentOS 5. sys-unconfig is provided by initscripts – James L Mar 1 '11 at 14:47
  • oops, you're correct, the old sysconfig file threw me. I'll delete the first comment to not mislead anyone ;) – JimB Mar 1 '11 at 14:50

The /etc/sysconfig/static-routes file is deprecated, and it uses the route command syntax, which is also deprecated.

You can drop rules using the ip syntax for the eth0 interface in the file:


There's no hook to do this directly in a kickstart file, so you would have to do it in the %post section.

|improve this answer|||||
  • The netinstaller needs this to be set before it can start the installation. Am I going to have to find another way to do this? I could install it with NAT/guest and switch to bridging post install I guess. – James L Mar 1 '11 at 16:41
  • Although I don't understand the reasons for your unusual network layout here, my personal preference here would be to install using a basic network config (i.e. NAT), and do final configuration post-install. Creating a "template" VM image per @dynasny's answer is a good idea as well. – JimB Mar 1 '11 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.