Netinstalling CentOS if the gateway is in a different subnet

Posted by James Lawrie on Server Fault See other posts from Server Fault or by James Lawrie
Published on 2011-03-01T11:48:13Z Indexed on 2011/03/01 15:26 UTC
Read the original article Hit count: 374

Filed under:
|
|
|
|

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?

© Server Fault or respective owner

Related posts about networking

Related posts about centos