Hello readers, in this post we will learn how we can set up static IP address to the Virtual machines created using Oracle Virtual Box.
In case you want to install Oracle Virtual Box and deploy a Linux VM like Ubuntu or Centos on it, please read old post with detailed steps.
When we created these virtual machines, they have IP address assigned which are from the bridged adaptor on my Wi-Fi router network. So, the ip address that my virtual machines are getting are assigned by the Wi-Fi router using dhcp. As the IPs assigned by the DHCP router are dynamic so they can change anytime when you reboot the machines. Sometimes, when you reboot the machines, you will find that the IP address assigned got changed than the one they had before.
So, in case you want to have your virtual machines to have static IP address, this cannot be achieved using the bridged network, so a alternate way is to create another network that will be host only network.
It will be a network on my Laptop and my laptop will have a virtual interface on that network and all of the virtual machines will have a virtual interface on that network and we can assign static IPs for the VMs on that network.
In this post, we have performed steps on CentOS 7.9 Linux VM.
Open Host Network Manager from the File menu or Network option from the Tools menu
Adapter 1 with Bridged Network for internet access
# cd /etc/sysconfig/network-scripts
# vi ifcfg-enp0s8
NAME=enp0s8
DEVICE=enp0s8
BOOTPROTO=none
DEFROUTE=yes
ONBOOT=yes
PREFIX=24
IPADDR=192.168.56.2
save and quit the file.
Restart the network service using below command
# systemctl restart network
0 comments:
Post a Comment