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?
The
/etc/sysconfig/static-routes
file is deprecated, and it uses theroute
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.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, underthen 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 bysys-unconfig
. And whatever else you add to rc.sysinit as well of course.