Netinstalling CentOS if the gateway is in a different subnet
- by James Lawrie
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?