©2015 - 2022 Chad’s Technoworks. Disclaimer and Terms of Use

Chad’s TechnoWorks My Journal On Technology

Information Technology

VIRTUAL BOX GUEST OS INSTALLATION - page 4

 Prev< 1 2 3 4 5 6 7 >Next

5. Configure Local Host Network


By default, a newly created Guest OS only has a NAT interface and nothing outside the Guest Host can connect to it.

You can define a network segment for DHCP for a group of VMs to allow these VMs to communicate each other and to allow terminal access. This can be done by adding a Host-only Network interface onto your VM instances which can be configured at the Virtual Box. You can also create 2 different networks and provide the interface to target VMs to represent a public and backend internal network.

A Host-only Network in Virtual Box allows you to define a range of IPs for your DHCP.


In this example, I'll be creating a single network segment and add a network interface attached to this segment onto the newly created VM (Linux Node 1).


5.1. Create A Host Network


Go to the Virtual Box Preferences, then select Network.

Select "Host-only Networks" tab, then click the + icon to add a new network segment.

This will create vboxnet0 network with DHCP.

You may examine the assigned network IP range by either hovering your mouse onto the network name or by invoking the edit.

Notice that the network segment is in the 192.168.56.1 network and the DHCP server (192.168.56.100) is enabled which would assign dynamic IP from 192.168.56.101 up to 192.168.56.254.  

5.2. Add A Network Interface Onto A VM


The next step is to add a network interface to the VM (Linux Node 1) attached to the network segment vboxnet0.


Go to the VirtualBox Manager Window and select your target VM and click Settings icon, then select the Network tab.

You'll notice that Adapter 1 is already configured attached to a NAT which was done during the VM setup earlier.

This NAT gives your VM the ability to access internet.

We need to configure another network adapter for our host network (vboxnet0).

Click on Adapter 2 tab and enable the adapter and then attach it to Host-only Network.

Click OK button when done to save your changes.

At this point, the VM now has an additional network interface. By default in Linux, this interface is configured with DHCP and will have an IP based on the range you defined in your Host-only Network. You can verify your assigned IP when you boot your VM. Just run ifconfig -a from the terminal and you'll see a new eth1 interface with the assigned IP.


HOW TO CONFIGURE (PERMANENT) STATIC IP FOR VIRTUAL BOX LINUX GUEST OS


Assigning a static IP for your Guest OS allows you to have a permanent IP for your application to connect to. This is particularly necessary for database and web server hosts.

By default, once you got a local host configured for your Guest OS, it is assigned a dynamic IP via DHCP which varies depending on the order of which you start the Virtual Box VMs.

To have a more consistent host IP, you need to reconfigure the network interface properties in your Guest OS.


The following is an example of a static IP network configuration for Linux.


PREREQUISITE: You must have already configured a local host network in Virtual Box and assign it to the Guest OS. See - Configuring Local Host Adapter.


Network Configuration Using Desktop GUI

1. From the Red Hat 6 Menu, go to: System -> Preferences -> Network Connections. Then, select the local host interface (usually eth1) to edit.


2. Set the static IP properties.

NOTE: By default, this interface is configured with DHCP. Since we plan to assign a permanent IP, we have to use a Manual method of configuration. What this means - we need to pick an available IP within the defined IP range of your local host adapter you've created previously in virtual box. However, this local host adapter has a predefined IP range for DHCP and in my case it is 192.168.56.101 up to 192.168.56.254. Since these IPs are reserved (including DHCP server 192.168.56.100), we can only assign a permanent static IP from 192.168.56.1 to 192.168.56.99.


[x] Connect Automatically

[x] Available To All Users

IPv4 Settings:

Method: Manual

Addresses [Add]

Address: 192.168.56.11

Netmask: 255.255.255.0

Gateway: 0.0.0.0

DNS Servers: leave it blank if you don't have any DNS service running on this network segment.

Search Domains: leave it blank if you don't have any public or internal domain name.

3. Update your hosts file (/etc/hosts) in both the Host OS and Guest OS to specify your permanent host IP if you don't have a DNS to resolve the IP.


Example:


##

# Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting.  Do not change this entry.

##

127.0.0.1 localhost

255.255.255.255 broadcasthost

::1             localhost

#

##-- VirtualBox Local VM Hosts

192.168.56.11   lxnode11.vlabs.net lxnode11

192.168.56.12   lxnode12.vlabs.net lxnode12

192.168.56.13   lxnode13.vlabs.net lxnode13

192.168.56.14   lxnode14.vlabs.net lxnode14