NAT loopback with virtualbox not working
I have a problem with my server & virtual server setup.
I have one linux server with 2 IPs from my provider, the provider does not alllow different MAC addresses on the switch, so I have to use NAT.
On my server there's virtualbox running with am Ubuntu virtual machine inside.
This machine is connected via a host-only network to the host.
So the host looks like this:
eth0 inet addr:81.169.xxx.xxx
eth0:1 inet addr:85.214.xxx.xxx
vboxnet0 inet addr:192.168.56.1
On the virtual client like this:
eth0 inet addr:192.168.56.101
On my host I have the following iptables setup:
This is working okay, the VM client can reach the internet and I can reach the services via the second IP of the host.
INTIP="192.168.56.101" #Internal VM
EXTIP2="85.214.xxx.xxx" # External IP 2
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -t nat -A PREROUTING -d $EXTIP2 -j DNAT --to $INTIP
iptables -t nat -A OUTPUT -d $EXTIP2 -j DNAT --to $INTIP
One thing isn't working though: The client cannot reach itsself via the internet IP :(
This is quite annoying, because some services try to lookup themselves through the internet IP and of course fail.
What can I do to make this work?
I've read in many tutorials that for this "nat loopback" you need to modify the source address to the external interface, so I tried this:
iptables -t nat -A POSTROUTING -s $INTIP -d $INTIP -j SNAT --to $EXTIP2
but this is not working either :(
Any help would be greatly appreciated!