How can I troubleshoot Virtualbox port forwarding from Windows guest to OSX host not working?

23
2013-09
  • joe larson

    There are a plethora of questions about virtual box port forwarding problems but none with my specific details.

    I have a Windows install living in Virtual Box, hosted within OSX. I've got several webservers running on localhost on different ports within the Windows install. I cannot for the life of me get port forwarding to work so I can access those webservers from OSX.

    My settings look like this (yes I have a NAT adapter):

    enter image description here

    And in my vbox configuration file the relavent portion looks like this:

    <NAT>
            <DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
            <Alias logging="false" proxy-only="false" use-same-ports="false"/>
            <Forwarding name="RLPWeb" proto="1" hostport="7084" guestip="127.0.0.1" guestport="7084"/>
            <Forwarding name="UtilWeb" proto="1" hostport="4040" guestip="127.0.0.1" guestport="4040"/>
            <Forwarding name="WCARLP" proto="1" hostport="8084" guestip="127.0.0.1" guestport="8084"/>
            <Forwarding name="WCAUtil" proto="1" hostport="4848" guestip="127.0.0.1" guestport="4848"/>
          </NAT>
    

    I've turned off the Windows firewall to ensure it is not interfering, and I am not running a firewall on OSX.

    Anyway, when I attempt to go to for example http://127.0.0.1:4040/ on any of my OSX browsers, it will eventually time out.

    The log file for this VM shows that it is correctly reading the settings and implying it's doing the right thing here:

    00:00:08.286 NAT: set redirect TCP host port 4848 => guest port 4848 @ 127.0.0.1
    00:00:08.286 NAT: set redirect TCP host port 8084 => guest port 8084 @ 127.0.0.1
    00:00:08.286 NAT: set redirect TCP host port 4040 => guest port 4040 @ 127.0.0.1
    00:00:08.286 NAT: set redirect TCP host port 7084 => guest port 7084 @ 127.0.0.1
    00:00:08.290 Changing the VM state from 'LOADING' to 'SUSPENDED'.
    00:00:08.290 Changing the VM state from 'SUSPENDED' to 'RESUMING'.
    00:00:08.290 Changing the VM state from 'RESUMING' to 'RUNNING'.
    00:00:08.337 Display::handleDisplayResize(): uScreenId = 0, pvVRAM=000000012017d000 w=1834 h=929 bpp=32 cbLine=0x1CA8, flags=0x1
    00:00:09.139 AIOMgr: Host limits number of active IO requests to 16. Expect a performance impact.
    00:00:13.454 NAT: DHCP offered IP address 10.0.2.15
    

    I've tried setting the Host IP to 127.0.0.1, and I've tried setting Guest IP blank and also 10.0.2.15. None of these seem to help.

    What else can I look at to troubleshoot this issue?

    Details of setup:

    • OSX 10.6.8
    • Windows 7 Professional 64bit
    • VirtualBox 4.1.2
  • Answers
  • PeteS

    I have noticed problems with port forwards on OSX VirtualBox host.

    Using network adapter PCnet-Fast III (Am79C973) and Oracle Developer Day image as guest.

    When ever I suspend the guest and resume it all port forwards are lost.

    I am not certain if the problems are related to the network adapter or to the guest but I fail to see how the guest could be aware of the port forwards.

    This is a long shot, but if you have anything in common with this case, try shutting down (complete power off of the guest) and starting up with the port forwards set. Immediately test if any of the port forwards work and only after positive results try suspending and resuming the guest.


  • Related Question

    networking - VirtualBox NAT port forwarding on Ubuntu 64?
  • Greg Mattes

    I have an Ubuntu 9.04 desktop 64-bit guest OS running on an Ubuntu 9.04 desktop 64-bit host OS (yes, the same OS). I'd like to run a web server on the guest and make it accessible through NAT on the host.

    I (think I) followed the VirtualBox port forwarding instructions, but the guest/VM won't start after I do the configuration.

    Here's the configuration that I ran:

    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8080
    

    Where <Guest Name> is the name of the guest VM image.

    The error looks like this:

    enter image description here

    The same error happens regardless of whether I run the configuration while the VM is running, or not running.

    Guest additions are installed.

    How do I properly configure the NAT port forwarding? What is causing this error?


  • Related Answers
  • the_curator

    get all param you did for this WM with command:

    VBoxManage.exe getextradata "Name_of_VM" enumerate
    

    You should see all value transmited to VM.

    Key: GUI/SaveMountedAtRuntime, Value: yes
    Key: GUI/ShowMiniToolBar, Value: yes
    Key: GUI/MiniToolBarAlignment, Value: bottom
    Key: GUI/LastCloseAction, Value: save
    Key: GUI/LastWindowPostion, Value: 345,133,640,522
    Key: GUI/Fullscreen, Value: off
    Key: GUI/Seamless, Value: off
    Key: GUI/AutoresizeGuest, Value: on
    Key: GUI/MiniToolBarAutoHide, Value: on
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort, Value: 22
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort, Value: 22
    

    Remove all ligne begin with VBoXInternal by Copying and paste the line to command like this

    VBoxManage.exe setextradata "Name_of_VM" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort"
    

    with no value to the end. At end you should enumerate again and see no more lines of VBoxInternal.

    Now you can make again the NAT rules, with different name for rules.

    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort, Value: 2222
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort, Value: 22
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol, Value: TCP
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol, Value: TCP
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort, Value: 80
    Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort, Value: 8080
    

    Under linux you should remind that PORTS <1024 should NOT be redirected. use 2222 for guestssh and 8080 for guesthttp (Example) For ease of use I personnaly use <1014 port under WINDOWS.

    Hope this should help you.

    (Sorry For English! I'm frenchy :P)

    Jacques.guensherian

  • catchdave

    I had the same symptom when I setup up port forwarding in VirtualBox.

    When I create new VMs in VirtualBox, the default network adapter is e1000, not pcnet as per the instructions you followed.

    If you modify the config settings to:

    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guesthttp/Protocol" TCP
    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guesthttp/GuestPort" 80
    VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/e1000/0/LUN#0/Config/guesthttp/HostPort" 8080
    

    This should solve your problem.


    The above configuration option will work for the first e1000 adapter, hence the e1000/0 in the settings. Double check which network adapter is being used by the VM you are trying to port forward to.

    On my installation, the network adapters available are two "PcNet" ones and three "Intel Pro 1000".

    The adapters are referred to by the following keys:

    • First PCNet: pcnet/0
    • Second PCNet: pcnet/1
    • First Intel PRO/1000: e1000/0
    • Second Intel PRO/1000: e1000/1
    • Third Intel PRO/1000: e1000/2

    If your adapter is, for example, the second "PRO/1000" in the list, then you need to modify the above config to e1000/1 (etc).