How to add a static ip address to a linux distribution such as Debian running as a VPS on VirtualBox
Ensure the VM is powered off
-
Configure the Network
Settings -> Network
-
Ensure Adapter 1 is attached to NAT and Adapter 2 is attached to Host-only Adapter
-
Ensure your host’s IP is set similar to the following
-
Get the names of your network interfaces, make a note of them
ip addr
-
Open the interface file in Nano
su
cd /etc/network
nano interfaces
-
Ensure the interfaces are configured as the following. Use your own interface names e.g in the following the interface names are enp0s3 and enp0s8.
source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # Adapter 1 allow-hotplug enp0s3 iface enp0s3 inet dhcp # Adapter 2 auto enp0s8 iface enp0s8 inet static address 192.168.56.102 netmask 255.255.255.0 gateway 192.168.56.1 nameserver 8.8.8.8
-
reboot Debian
reboot