VirtualBox Setup Host Only Adapter Static IP

September 27, 2020

Setup Host-only Adapter.

By default, the host only adapter have a DHCP which assigned ip between 192.168.56.101 to 192.168.56.254. You can limit the ip range by configuring the DHCP via VirtualBox -> File -> Host Network Manager.

You can check your assigned IP via ifconfig -a, where enp0s8 is Host-only Adapter.

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::6985:240e:c74:951d  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:4f:1c:84  txqueuelen 1000  (Ethernet)
        RX packets 39  bytes 5879 (5.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 9487 (9.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::506e:b210:fa8c:2a3b  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:d7:b0:01  txqueuelen 1000  (Ethernet)
        RX packets 10  bytes 1785 (1.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 29  bytes 4205 (4.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 35  bytes 3839 (3.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 35  bytes 3839 (3.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Enable Static IP

sudo nano /etc/network/interfaces
# Host-only
auto enp0s8
iface enp0s8 inet static
  address 192.168.56.101
  netmask 255.255.255.0

Install sudo apt-get install ifupdown to test if the configuration is successful.

Restart the network interface

sudo ifdown enp0s8
sudo ifup enp0s8

NOTE: You can test via service networking status or systemctl restart NetworkManager or reboot the client.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.