0

I created a NAT Network in VirtualBox and from the Ubuntu host I am trying to SSH into the Ubuntu server VM, but I get connection refused. The Ubuntu server VM is connected to the NAT Network using port forwarding. I can connect successfully with port forwarding if I set NAT instead of NAT Network in the adapter, but for this assignment I have to use NAT Network.

Can anybody help? I have already spent many hours trying to solve this. I think the problem might be with the Ubuntu host and not with VirtualBox, but still can't figure out the solution.

Host: Ubuntu 18.04.1. LTS

VirtualBox: 5.2.18_Ubuntu r123745

Guest: ubuntu-16.04.5-server-i386

Guest Network Settings:

guest machine network adapter

NAT Network:

NAT Network settings

Port Forwarding Rules:

port forwarding rules

Guest Network Interfaces:

output of ifconfig on guest VM

Failing SSH connection

root@ThinkPad:~# ssh -vvv user@127.0.0.1 -p 1022
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "127.0.0.1" port 1022
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 1022.
debug1: connect to address 127.0.0.1 port 1022: Connection refused
ssh: connect to host 127.0.0.1 port 1022: Connection refused

Update

  • I have changed the entry port for the forwarding from 1022 to 10001, because with port 1022 forwarding wasn't working with NAT either.
  • When I use port 10001 for forwarding, I can see the on the host VirtualBox is actually listening on that port:
root@giacomo-ThinkPad:~# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10001           0.0.0.0:*               LISTEN      2482/VirtualBox     
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1489/dnsmasq    

Instead when using the same forwarding rules with NAT Network, VirtualBox is not listening. So it looks like the problem might be in VirtualBox?

0

The problem was solved by installing VirtualBox 6.0. With it everything port forwarding from localhost:10001 started working also with NAT Network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.