Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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  
    done  
    route add default gw "${GATEWAY}"  
fi  

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?

share|improve this question

2 Answers 2

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.

share|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:

/etc/sysconfig/network-scripts/route-eth0

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

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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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