- make sure that there is a host-only network to connect to.
To check if you already have one, start VirtualBox and then click on the Global Tools button and make sure you are on the Host Manager Network tab.
Take note of the IP Address of the network and the network mask. For example in the screenshot below, the IP Address is 192.168.99.1 with network mask of 255.255.255.0 which means you can assign IP addresses 192.168.99.2-254 statically
- Disable the DHCP server since you will assign IP addresses statically
- make sure that the VM is shut down
- in the VirtualBox app select the VM and click on the Settings button. Click on the Network tab. Adapter 1 should be your NAT adapter. Click on the Adapter 2 subtab, select Host-only Adapter and the name of the host-only network
- Click OK and start up the VM. Log in as root through VirtualBox console. Run
$ ip addr
- Create a file called
/etc/sysconfig/network-scripts/ and give it the following contents:
NETMASK should match the settings for your host-only network as obtained above and
IPADDR should be an available IP address in the host-only network
Finally, you can restart and find that your IP does not change
$ systemctl restart network
$ ip addr