Ubuntu Svr VM in VirutalBox gets no IP on Bridged Network, unreachable via NAT IP

Ubuntu Svr VM in VirutalBox gets no IP on Bridged Network, unreachable via NAT IP

I've setup an Ubuntu Server 18.04 VM in VirutalBox on my Lenovo laptop (which is running Ubuntu Desktop 18.04). When the VM boots up using NAT for networking, it does get an IP and it can get out to the internet (PING google, etc): 10.0.2.15

However, I cannot get in to the VM via SSH, nor does PING work or anything else - nothing inbound to the VM is being allowed. I tried to disable UFW like so: systemctl stop ufw ...which did disable UFW, but still nothing inbound is being allowed at all.

I then tried setting the NIC to use "Bridged" networking, but it cannot get an IP from DHCP (not sure why). I'm fine with using either IP, it doesn't matter. I just need inbound connectivity. How can I get it?

答案1

Make sure that sshd.service is enabled and listening on desired port on the VM. Also make sure that ssh ports are open in the firewall on both the host machine and the virtual machine. Or the firewall turned off on each.

If you use NAT then you must setup port forwarding on on the VM NIC through the VM Manager 'Machine->Settings->Network' Under advanced. Or by using vboxmange in terminal.

vboxmanage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

If you use bridged mode for the VM NIC, then it will receive an IP address from your router. The same router that your host machine receives from. And there will be no need for port forwarding. Default NAT internal address will be in the 10.0.*.* range. Bridged address will be in range of your LAN router. Most home routers default to the range of 192.168.1.100

Oracle® VM VirtualBox®

相关内容