Weird socket behavior in VirtualBox (NAT + PAT)?
Posted: 14. May 2014, 22:55
I originally posted this on ServerFault but it's also appropriate here. I wasn't able to find much documentation on this, probably because it's such an unusual issue to search for.
I have a Linux VM with NAT and PAT configured. Let's say ports 2000 and 2001 are forwarded to the VM. These ports are also configured for external access on a device such as a router using a domain name such as mydomain (I don't have permission to add "dot com", but it should still be clear). The following command is first run:
This service can be tested locally and externally:
Now we test port 2001 which is not currently listening on the guest:
The problem is nc -v mydomain 2001. The connection should be refused. It looks like VirtualBox automatically binds to forwarded ports on the host machine regardless of whether those ports are being listening to on the VM. How can this be resolved? Do I need to configure proxy settings?
I have a Linux VM with NAT and PAT configured. Let's say ports 2000 and 2001 are forwarded to the VM. These ports are also configured for external access on a device such as a router using a domain name such as mydomain (I don't have permission to add "dot com", but it should still be clear). The following command is first run:
Code: Select all
nc -klv 2000 # listens on port 2000Code: Select all
nc -v localhost 2000 # Connection success
nc -v mydomain 2000 # Connection successCode: Select all
nc -v localhost 2001 # Connection refused
nc -v mydomain 2001 # Connection success (socket closes immediately after)