Page 1 of 1

NAT port forwarding to the hosts IP works, but not to others

Posted: 3. Apr 2013, 04:13
by davidparks21
I am running virutalbox on Windows 7.
The host VM OS is Ubuntu server 12.10.

Within the Host VM I've got eth0, which talks via the NAT interface fine, and I've configured a bridge br0 such that 2 LXC containers (VMs within Ubuntu) have IPs on the same subnet and bridge to eth0.

When I set up a port forward to the host OS's IP, no problem, it forwards the request just fine.

But it fails when I set up a port forward to the IP of one of the LXC containers (the IP of one of the other interfaces connected via br0 to eth0). Actually virtualbox will not even open the listening port on my Windows 7 host.

As soon as I change the IP ot the main Ubuntu Server host, voila, we have a listening port on windows 7, but when I change the port forward to one of the LXC containers, the listening port on windows 7 is gone.

Is there some rule against port forwarding to an IP other than the hosts? In this case the host has been configured with a static IP itself.

Re: NAT port forwarding to the hosts IP works, but not to ot

Posted: 3. Apr 2013, 11:19
by noteirak
Port forwading in Virtualbox works like a server daemon, it will try to open the port on local interfaces. If you try to create port forwarding on an IP or interface that doesn't exist, it will basically try to listen to a port on that specific IP or internface, and will obviously fail since it doesn't exist.

You are confusing this with NATing & Routing, which are the process to actually forward data and/or connections to IPs others than your own.

Re: NAT port forwarding to the hosts IP works, but not to ot

Posted: 3. Apr 2013, 11:21
by mpack
I don't understand your question.

Port forwarding is a feature of NAT networking. Because the only IP address visible to the outside world is that of the host, normally the guest will not receive unsolicited messages (since they are caught by the host). But, you can set up port forwarding to change that behaviour on some host TCP ports.

My understanding may be faulty, but AFAIK the feature is only relevant to the host IP address and only when the guest is using NAT networking. There is no forwarding going on (rather: there shouldn't be) when the guest is using bridged networking. There certainly should be nothing going on if messages are received by anything except the host.

Re: NAT port forwarding to the hosts IP works, but not to ot

Posted: 3. Apr 2013, 11:25
by davidparks21
Seems like this is my mistake. I've successfully gotten this working, but it fails sporadically. This may or may not still be an issue with virtualbox, but I've got some people on the LXC forum looking at the issue with me. It seems that the bridged networking of the host, operating under the NAT of the virtual machine is not working always. Sometimes it does work, but sporadically the networking doesn't behave properly.