Setup NAT and Host only Network on Oracle VM VirtualBox.

Ronn Wilder
2 min readNov 12, 2017

--

In order to connect to internet and to connect to host and other VMs, 2 network adapters are needed for the VM. One is NAT and other one is Host only adapter.

I hope you have already setup a VM. Now power off your VM and open network settings. Set the first adapter to NAT and second adapter to Host-only adapter.

First network adapter — NAT.
Second Network Adapter — Host-only Adapter.

Now start the VM, and check ifconfig. If it shows three adapters — for ex (enp0s3, enp0s8, lo) i.e., enp0s3 is for connecting to internet, enp0s8 is for connecting to host and other VMs and lo is loopback adapter to connect to itself, then adapters are already setup. Nothing to do further. But they aren’t. There are only two adapters, that’s why we are here.

Open the following file with root permissions —

sudo vim /etc/network/interfaces

Make the following entry in the end and save the file.

auto enp0s8
iface enp0s8 inet static
192.168.56.101

you can change the last block in the IP address to be 102, 103 etc. for different VMs.

you can use sudo ifup enp0s8 up command switch on the interface we just created and then restart the network service bysudo /etc/init.d/networking restart but I recommend you reboot your VM to make sure.

sudo reboot

Now try to ping google.com or something to check if it is connecting to internet. It will since NAT is working.

Try ssh 192.168.56.101. It will work this time.

Enjoy……

--

--

Ronn Wilder
Ronn Wilder

No responses yet