Page 1 of 1

Port forwarding to static IP on guest not binding

Posted: 10. Jun 2014, 23:08
by PatrickVBOX
Trying to port forward from host (Mac OS X) 127.0.0.1:8282 -> guest (CentOS)'s 10.10.10.10:8080. Existing port forwards include 127.0.0.1:8181 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:

Code: Select all

VBoxManage modifyvm "VM name" --natpf1 "rule3,tcp,127.0.0.1,8282,10.10.10.10,8080"
Here is how the working ones were added:

Code: Select all

VBoxManage modifyvm "VM name" --natpf1 "rule1,tcp,127.0.0.1,8181,,80"
VBoxManage modifyvm "VM name" --natpf1 "rule2,tcp,127.0.0.1,9191,,9090"
And by "non-working", I of course mean not listening (as a prerequisite to forwarding):

Code: Select all

$ lsof -Pi -n|grep Virtual|grep LISTEN
VirtualBo 27050 user   21u  IPv4 0x2bbdc68fd363175d      0t0  TCP 127.0.0.1:9191 (LISTEN)
VirtualBo 27050 user   22u  IPv4 0x2bbdc68fd0e0af75      0t0  TCP 127.0.0.1:8181 (LISTEN)
There should be a similar line above but with 127.0.0.1:8282.

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 10.10.10.10) 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 www . virtualbox . org /manual/ch06.html, 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:
    • 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
    • This forum link www . virtualbox . org /ticket/5654 -- 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?).make sure).
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).

Re: Port forwarding to static IP on guest not binding

Posted: 10. Jun 2014, 23:19
by noteirak
Give a VM log file with the three rules configured, and we'll see what Virtualbox has to say about it.

Re: Port forwarding to static IP on guest not binding

Posted: 10. Jun 2014, 23:21
by PatrickVBOX
Sorry, which file specifically? There's quite a few files in ~/Library/VirtualBox -- not sure which they need?

Re: Port forwarding to static IP on guest not binding

Posted: 10. Jun 2014, 23:50
by noteirak
See viewtopic.php?f=24&t=48476 under Guest Log File. It is also located in the subdirectory "Logs" in the VM folder

Re: Port forwarding to static IP on guest not binding

Posted: 12. Jun 2014, 16:37
by PatrickVBOX
Log file is attached as "bad.log"; you'll note the two successful NAT entries are there, but no mention at all of the one that doesn't take. I've also attached "good.log" which is the same guest running on a different host (both Mac OS X). For some reason, port forwarding works on the latter to the static IP, but not on the former. I'm at a loss ..

Non-working host (bad.log)

Code: Select all

00:00:02.074193 Changing the VM state from 'CREATED' to 'POWERING_ON'.
00:00:02.074234 NAT: set redirect TCP host port 8181 => guest port 80 @ 10.0.2.15
00:00:02.074346 NAT: set redirect TCP host port 9191 => guest port 9191 @ 10.0.2.15
...
00:01:10.650152 NAT: DHCP offered IP address 10.0.2.15
Note that I'm awaiting the output of "VBoxManage showvminfo [guest]" and will update thread once I have it.

Working host (good.log)
And below are the entries on the host that DOES work fine. What's interesting is that the port forward to the static entry is applied immediately power on (makes sense), and then later after DHCP gets an IP, the others are set up. Contrast this with the above, non-working host, where

Code: Select all

00:00:01.229157 Changing the VM state from 'CREATED' to 'POWERING_ON'.
00:00:01.229195 NAT: set redirect TCP host port 8282 => guest port 8080 @ 10.10.10.10
00:00:01.229442 AIOMgr: Endpoints without assigned bandwidth groups:
...
00:00:35.136857 NAT: DHCP offered IP address 10.0.2.15
00:00:35.136893 NAT: set redirect TCP host port 9191 => guest port 9191 @ 10.0.2.15
00:00:35.136993 NAT: set redirect TCP host port 8181 => guest port 80 @ 10.0.2.15

Re: Port forwarding to static IP on guest not binding

Posted: 12. Jun 2014, 16:51
by noteirak
Once you've got the showvminfo output on both hosts, we'll know more. but so far looks like a configuration error.

Re: Port forwarding to static IP on guest not binding

Posted: 12. Jun 2014, 16:55
by PatrickVBOX
Yeah, I've seen it configured in the GUI and looks correct. Like I said, remove the guest IP and it works fine. Add it back in to match eth1 (10.10.10.10) and the local binding (i.e., just disappears as confirmed by `lsof -Pi -n|grep Virtual`). Updating soon as I get the output though, thanks!

Re: Port forwarding to static IP on guest not binding

Posted: 12. Jun 2014, 20:58
by PatrickVBOX
The config for the non-working host is attached. As you can see, the NIC rule seems fine (it matches the working one exactly, save for their ordering which I really can't imagine would matter?). Note: MACs have been replaced to protect the innocent.

"Bad" config NIC settings:

Code: Select all

...
NIC 1:           MAC: [MAC#1], Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = Back-end, protocol = tcp, host ip = 127.0.0.1, host port = 9191, guest ip = , guest port = 9191
NIC 1 Rule(1):   name = Front-end, protocol = tcp, host ip = 127.0.0.1, host port = 8181, guest ip = , guest port = 80
NIC 1 Rule(2):   name = RESTful, protocol = tcp, host ip = 127.0.0.1, host port = 8282, guest ip = 10.10.10.10, guest port = 8080
NIC 2:           MAC: [MAC#2], Attachment: Internal Network 'intnet', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           MAC: [MAC#3], Attachment: Internal Network 'intnet', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
"Good" config NIC settings

Code: Select all

NIC 1:           MAC: [MAC#1], Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = RESTful, protocol = tcp, host ip = 127.0.0.1, host port = 8282, guest ip = 10.10.10.10, guest port = 8080
NIC 1 Rule(1):   name = Rule 1, protocol = tcp, host ip = 127.0.0.1, host port = 8181, guest ip = , guest port = 80
NIC 1 Rule(2):   name = Rule 2, protocol = tcp, host ip = 127.0.0.1, host port = 9191, guest ip = , guest port = 9191
NIC 2:           MAC: [MAC#2], Attachment: Internal Network 'intnet', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           MAC: [MAC#3], Attachment: Internal Network 'intnet', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Re: Port forwarding to static IP on guest not binding

Posted: 12. Jun 2014, 21:09
by noteirak
Please put them in the same order and give them the exact same names - you might hav discovered a bug here