Port forwarding for IPv4 and IPv6?

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
ajmas
Posts: 79
Joined: 27. Jan 2009, 19:37
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Ubuntu
Location: Olympus Mons Colony, Mars

Port forwarding for IPv4 and IPv6?

Post by ajmas »

Can anyone tell me whether port forwarding can do both IPv4 and IPv6 at the same time?

Currently I have a guest VM running Ubuntu 18.04.1 LTS, with an Nginx server running on port 80 & 443. This is port forwarded to 8080 and 8443 on the host OS.

Result of using wget to connect to Nginx from guest VM:

Code: Select all

   wget "http://localhost/" --> works
   wget "http://127.0.0.1/" --> works
   wget "http://[::1]/" --> works
and on host OS:

Code: Select all

  wget "http://localhost:8080/" --> works
  wget "http://127.0.0.1:8080/" --> works
  wget "http://[::1]:8080/" --> Connection refused.
  wget -6 "http://localhost:8080/" --> Connection refused.
Doing an 'lsof' on the host I see 8080 is only bound to IPv4, while in guest it is IPv6 (which supports both IPv4 and IPv6).

Note, I did initially provision this VM via Vagrant, but this seems to be more an issue at the VB level?

In the VB port forwarding dialogue

Code: Select all

Protocol  Host IP      Host Port   Guest IP   Guest Port
--------  -----------  ----------  ---------  ---------
  TCP     127.0.01     2222                   22
  TCP                  8080                   80
  TCP                  8443                   443
lsof output on guest:

Code: Select all

COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 2711 root    4u  IPv6  26305      0t0  TCP *:http (LISTEN)
lsof output on host:

Code: Select all

COMMAND     PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
VBoxHeadl 77727 userx   17u  IPv4 0xac95ec5790dd279d      0t0  TCP *:http-alt (LISTEN)
VB version: 6.x Primary OS: MacOS X 11.0.1 on Intel Mac
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Port forwarding for IPv4 and IPv6?

Post by socratis »

ajmas wrote:Note, I did initially provision this VM via Vagrant, but this seems to be more an issue at the VB level?
The one area that Vagrant screws up royally in VirtualBox, is networking. From custom networks, to specific port forwarding rules, to name it. Please completely uninstall Vagrant, make sure that it hasn't tainted your "VirtualBox.xml" and then create a new Vagrant-less VM. See what you get...

But to tell you the truth, I haven't seen any IPv6 port forwarding rules so far, only IPv4...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply