To assign static ip address on your VirtualBox VM instance, you’ll first need to setup a Host-Only network in VirtualBox Network Settings, add a new adapter in network of VM instance, assign static ip configuration in the OS present in VM instance.
Add Host-only Networks details
Click Host only network details icon:
In the Adapter tab add the following details:
IPv4 Address: 192.168.56.1IPv4 Network Mask: 255.255.255.0
You can have IP of your own choice.
In the DHCP Server tab add the following details:Server Address: 192.168.56.100Server Mask: 255.255.255.0Lower Address Bound: 192.168.56.101Upper Address Bound: 192.168.56.254
You can have IP of your own choice but the series should match what you entered in previous step.
Save the settings. Now we are going to edit the Network settings of specific VM instance.
Select your VM instance and then got settings of that instance.
Keep the "Adapter 1" setting as "NAT" only.
Go to "Adapter 2" setting and select "Host-only Adapter" option and then select the network you created in the first step.
We are all done with the settings of Host machine. We are going to play with settings of OS inside VM instance.
Go to Control Panel\All Control Panel Items\Network and Sharing Center of your Windows
Click "Ethernet 2" adapter.
In the TCP/IPv4 settings add the following settings:
IP address: 192.168.56.2
Subnet mask: 255.255.255.0
Default gateway: 192.168.56.1
Preferred DNS server: 192.168.56.1
Do note that I have added the settings based on the IP/ IP range we set in the adapter of Host. After setting the IP you can access your VM machine instance with the static ip you assigned.
You can confirm the connection by pinging it from Host machine:
You can further check by connecting it via Windows Explorer of Host machine: