VirtualBox Port Forward not working when Guest IP *IS* specified (while doc says opposite)

Posted by Patrick on Super User See other posts from Super User or by Patrick
Published on 2014-06-10T20:42:45Z Indexed on 2014/06/10 21:30 UTC
Read the original article Hit count: 68

Trying to port forward from host (Mac OS X) -> guest (CentOS)'s Existing port forwards include and 9191 to guest without any IP specified (so whatever it gets through DHCP, as explained in the documentation).

Here is how the non-working binding was added:

VBoxManage modifyvm "VM name" --natpf1 "rule3,tcp,,8282,,8080"

Here is how the working ones were added:

VBoxManage modifyvm "VM name" --natpf1 "rule1,tcp,,8181,,80"
VBoxManage modifyvm "VM name" --natpf1 "rule2,tcp,,9191,,9090"

And by "non-working", I of course mean not listening (as a prerequisite to forwarding):

$ lsof -Pi -n|grep Virtual|grep LISTEN
VirtualBo 27050 user   21u  IPv4 0x2bbdc68fd363175d      0t0  TCP (LISTEN)
VirtualBo 27050 user   22u  IPv4 0x2bbdc68fd0e0af75      0t0  TCP (LISTEN)

There should be a similar line above but with

Just to be clear, this port is listening perfectly fine on the guest itself. And when I remove the guest IP (i.e., clear the the forward works fine, albeit to eth0 (not eth1 where I need it). I can tcpdump and watch the traffic flow back and forth. And yes, I've disabled iptables entirely while testing -- it's not getting blocked anywhere on the guest.

As VirtualBox writes in their documentation, you are required to specify the guest IP if it's static (makes sense, no DHCP record it keeps): "If for some reason the guest uses a static assigned IP address not leased from the built-in DHCP server, it is required to specify the guest IP when registering the forwarding rule:". However, doing so (as I need to), seems to break the port forward with nary a report in any log file I can find. (I've reviewed everything in ~/Library/VirtualBox/).

Other notes:

  1. While I used the above command to add the third rule, I've also verified it showed up correctly in GUI and then removed/re-added from there just to make sure).
  2. This forum link -- while very dated -- looks somewhat related in that a port forward to a static IP was not appearing (perhaps they think due to lack of gratuitous arp being sent for host to know IP is there/avail?).

Anyway, what gives? Is this still buggy? Any suggestions? If not, easy enough workarounds? What's interesting is that this works perfectly fine on another user's Mac, however he's running a slightly older version (4.3.6 v. 4.3.12).

© Super User or respective owner

Related posts about linux

Related posts about networking