WHAT'S NEW?
Loading...

Ping Ubuntu server running in VirtualBox from outside

By default a guest machine in VirtualBox is configured to use so called NAT networking - the guest's network adapter's IP is in a "virtual" subnet which includes the guest and the parent VirtualBox application which acts as a gateway.

For the guest (Linux Server inside Virtual Box) it looks like it accessing internet via something like an ordinary ADSL modem, but the guest can't be accessed from anywhere, just like you can't access machines in your local network from Internet without specifically configuring your modem to allow such access.

If you need to access your guest from outside, you need to configure bridged networking, which will give your guest its own IP in your local network. The configuration is done in VirtualBox settings.  When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.

To enable bridged networking, all you need to do is to open the Settings dialog of a virtual machine, go to the "Network" page and select "Bridged network" in the drop down list for the "Attached to" field. 


Put a Static IP in VirtualBox Machine with Ubuntu 16.04

Set first Adapter to "Host-only Adapter" and second one to "NAT" and in this example you could successfully get IP set to "192.168.56.106" with following configuration. Here is my /etc/network/interfaces :
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Host Only Network
auto enp0s3
iface enp0s3 inet static
dns-nameservers 8.8.8.8 8.8.4.4
address 192.168.56.106
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255

# NAT Network
auto enp0s8
iface enp0s8 inet dhcp

The order of the network adapters in the VirtualBox settings makes the difference.
First one should be host-only, second one NAT.

0 comments:

Post a Comment