In this article, we will learn how to configure networking between the host machine and the guest virtual machine. Here I am using a host machine ( a system in which virtualization software (Virtualbox ) is installed ) as windows 10 and guest VM as centos-6.
To communicate with guest VM first we have to configure a network on the host machine. For this.
- Press Windows key + X to open user menu and then click network connections
- Right-click on the Ethernet adapter and select properties. Here I am using this adapter for the internet.
- Select internet protocol version 4 (TCP/IPv4) and click Properties. Here we can set up a static IP address.
For my convenience, I have used a class “C” IP address 192.168.1.100 with its network mask is 255.255.255.0 you can use any other private class IP address.
Once you setup the static IP, you can confirm it from the windows command prompt by running the ipconfig command.
Now, we have configured the network in our Host machine, then next is configure a network in guest VM. I have already installed a Centos-6 guest VM in my VirtualBox.
Before booting the guest VM, we should configure the network in the VirtualBox. For this Right-click on the guest VM -> Settings -> Select network. Tick the box to enable the first Adaptor and select the attached Bridged Adapter from the drop-down box.
The Bridged adapter act as a bridge between the virtual network and the physical network. The outside world can directly communicate with guest VM.
Next, we are going to configure the network in the guest machine. For this edit ifcfg-eth0 file as follows
ifcfg-eth0 is the ethernet interface configuration file. which controls the first network interface in the system.
set the following values
ONBOOT=yes: Device should be activated at the time of booting
BOOTPROTO=static: Use static IP address mentioned in the file
IPADDRESS: Give the IP address in the same range that we set for the host machine then only guest VM can communicate with the host machine.
Now we have set up a static IP address. Next, we have to set up a DNS name resolution, for this edit /etc/resolv.conf file
you can add your ISP nameserver or open DNS. Here I have used open DNS nameservers
Once all the above value set, then restart the network service
To confirm the IP address configuration run ifconfig command from the terminal
Now Both host and guest VM running on the same network, so we can log in to the guest VM from the host with the help of putty.
Open your putty ssh client enter remote host address as 192.168.1.102 enter username as “root”
Then click open and you can see a connection established to the guest VM centos terminal