Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VirtualBox Port Forwarding on Windows 7 not Working

VirtualBox Port Forwarding on Windows 7 not Working

Im trying to ssh onto my VirtualBox from my Windows 7 host via port forwarding, but VirtualBox wont open the port for listening. I can connect to it by turning on the VirtualBox GUI and navigating via that terminal, but I cannot connect via a standard ssh client from my host. I want to be able to ssh on port 2222 on my host to the guest.

Here's my setup:

Host: Window 7 SP1
Guest: Ubunto Ubuntu 12.04
VirutalBox: 4.3.26
Host Processor: Intel Core i7 920

The guest machine is configured as a NAT and port forwarding is enabled for 127.0.0.1 for host port 2222 to guest port 22.

The output from ifconfig on the guest:

eth0    inet addr:10.0.2.15 Bcast:10.0.2.255 Mask: 255.255.255.0

The output from ps -ef | grep sshd on the guest:

root    625 1   0   12:27   ?   00:00:00    /usr/sbin/sshd -D

The output from netstat -ant | grep 22 on the guest:

tcp     0   0   0.0.0.0:22  0.0.0.0:*
tcp6    0   0   :::22       :::*

But on the host, netstat -ant | grep 2222 doesnt show anything.

In the VBox.log however I have this:

00:00:03.413790 NAT: set redirect TCP host 127.0.0.1:2222 => guest 10.0.2.15:22
00:00:03.424301 supR3HardenedErrorV: supR3HardenedScreenImage/LdrLoadDll: rc=VERR_LDRVI_UNSUPPORTED_ARCH fImage=1 fProtect=0x0 fAccess=0x0 \Device\HarddiskVolume2\Windows\mfnspstd64.dll: WinVerifyTrust failed with hrc=Unknown Status 0x800B0101 on '\Device\HarddiskVolume2\Windows\mfnspstd64.dll'
00:00:03.424422 supR3HardenedErrorV: supR3HardenedMonitor_LdrLoadDll: rejecting 'C:\Windows\mfnspstd64.dll' (C:\Windows\mfnspstd64.dll): rcNt=0xc0000190
00:00:03.424476 NAT: failed to redirect TCP 127.0.0.1:2222 => 10.0.2.15:22

The last line looks like the suspect but there's no clue as to why it fails to redirect. I've tried all of the following from various other posts and forums but cant get it to listen on any port on the host:

  • Turned off the firewall
  • Changed the port
  • Enabled VT-X on BIOS
  • Disabled Hyper-V
  • Tried numerous different builds of VirtualBox

Any help would be much appreciated. Works fine on my Mac Book with OS-X.

like image 749
Sparm Avatar asked Apr 20 '15 10:04

Sparm


People also ask

How do I forward a port in VirtualBox?

To forward ports in VirtualBox, first open a virtual machine’s settings window by selecting the Settings option in the menu. Select the Network pane in the virtual machine’s configuration window, expand the Advanced section, and click the Port Forwarding button. Use VirtualBox’s Port Forwarding Rules window to forward ports.

How to create port forwarding on host only adapter?

With the Host Only Adapter your Host and Guest OS can communicate. With NAT the Guest connects to the internet. 1)Set 1 Host Only Adapter & 1 NAT adapter 2)Enable Virtual Box Network Adapter in your Host Machine. 3)Ping both Host and the Guest and ensure both are connected. 4)Now Create Port Forwarding on the Host Only Adapter.

How do I fix port forwarding port forwarding error?

Check you VM machine logs for the error message while setting up port forwarding and listing the unsigned drivers and uninstall the corresponding application. Show activity on this post. I am using CentOS 7 as host and Windows as guest.

How to configure port forwarding in Windows 10?

Click on the Network tab in Settings main interface. Look for and click on Advanced text at the bottom of the window. Click on Port Forwarding button. Click on the + icon on the upper right to add new port forwarding rule in Port Forwarding's main interface. Some of the fields are automatically filled up as the followings.


2 Answers

Did you set forwarding in machine settings ?

  1. To forward ports in VirtualBox, first open a virtual machine’s settings window by selecting the Settings option in the menu.

  2. Select the Network pane in the virtual machine’s configuration window, expand the Advanced section, and click the Port Forwarding button. Note that this button is only active if you’re using a NAT network type – you only need to forward ports if you’re using a NAT.

  3. Use VirtualBox’s Port Forwarding Rules window to forward ports. You don’t have to specify any IP addresses – those two fields are optional.

Also here: http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/

like image 135
Crowlex Avatar answered Oct 14 '22 06:10

Crowlex


I found the solution in a hypernode-vagrant issue: VirtualBox fails to establish the port forwarding for SSH on Vagrant's standard port 2222, but higher ports work. In that issue, ports >= 4000 worked, whereas ports <= 3500 would fail. On my machine running Windows 10, I found 2380 to be the first port for which the TCP redirect can be established.

The port on the host used for forwarding can be changed by adding the following lines to your Vagrantfile (where you may have to replace 4000 by a higher number):

config.vm.network :forwarded_port, guest: 22, host: 2222, disabled: true
config.vm.network :forwarded_port, guest: 22, host: 4000, id: "ssh"

I have no idea what the root cause for this behavior could look like, but the workaround has been working reliably so far.

like image 22
Fabian Meumertzheim Avatar answered Oct 14 '22 05:10

Fabian Meumertzheim