The setup consists of several Virtualbox VMs in hostonly mode each with its own interface.
The Virtual Machines get their IP-Adress and routing information through
dnsmasq on the host.
Port forwarding and masquerading are also configured and working fine.
iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
Connections from other hosts to the VM and connections from the Vms to other hosts work fine.
But if I try to ping the host from a VM I got the following error messages:
22.214.171.124 be the external IP for the host
martian source 126.96.36.199 from 10.60.1.100, on dev vboxnet0. ll header: 0a:00:27:00:00:0c:08:00:27:db:84:7f:08:00
My guess is that the masquerading rules rewrite the IP-address to the host address but they are not leaving one of the
eth interfaces but are going through loopback and therefore the kernel throws them away.
So I tried to add a new rule:
iptables -t nat -A POSTROUTING -o lo -j MASQUERADE
but had no luck either.
While setting up the server I've added some strict
sysctl rules in order to properly configure the network interfaces (This works fine)... but maybe here they could cause trouble?
net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.eth0.rp_filter = 1 net.ipv4.conf.eth1.rp_filter = 1 net.ipv4.conf.all.arp_ignore = 2 net.ipv4.conf.eth0.arp_ignore = 2 net.ipv4.conf.eth0.arp_announce = 2 net.ipv4.conf.eth1.arp_ignore = 2 net.ipv4.conf.eth1.arp_announce = 2 net.ipv4.conf.all.arp_filter = 1 net.ipv4.conf.eth0.arp_filter = 1 net.ipv4.conf.eth1.arp_filter = 1
I'd rather want to have a clean setup or at least some reasoning why this setup breaks - also the rules outlined here: http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.kernel.rpf.html seem to not apply to my situation.
route -n on the host:
0.0.0.0 188.8.131.52 0.0.0.0 UG 100 0 0 eth1 0.0.0.0 184.108.40.206 0.0.0.0 UG 200 0 0 eth0 10.60.0.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet0 10.60.1.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet1 ... 220.127.116.11 0.0.0.0 255.255.255.0 U 0 0 0 eth0 18.104.22.168 0.0.0.0 255.255.255.0 U 0 0 0 eth1