This website is preserved for historical and scholarly reference and is no longer actively maintained.

VirtualBox Introduction




VirtualBox Documentation

Here are a few items that are helpful

 

Installing a VM on VirtualBox 



Step 1.  Installing a VM. 

 

Step 2. Once you install the VM, you should install the VMs set of helpful drivers referred to as "Guest Addtions"

Step 3. Tweak your VM settings to enable these useful features::

 

Packages to install after a installing a Ubuntu VM

After a fresh install of Ubuntu, you should do a 'sudo apt-get update'. Then, ,issue 'sudo apt-get install xxx' the following.

To see all installed, 'apt-cache pkgnames', To see if a specific pkg is installed, like iperf, 'apt-cache showpkg iperf', And if you know the program you want to get but it is different from the package name, you can try 'apt-cache showpkg iperf'. It appears that are 16.04 release comes with at least some of these packages. So only install them if needed.

Additional setup on the VM (optional)

Network Setup

In this discussion, we add further details on the default virtual environment setup with VirtualBox with ubuntu 16.04 running as a Guest. From a TCP/IP perspective, we refer to the Guest as VM1 and the TCP/IP host that represents VirtualBox's Host and VMM as the Host. Any number of VMs can be created, with 1 or more virtual networks.

In this section, we overivew networking in a VirtualBox VM environment. Then we describe the setup required to support two different scenarios, one involving one VM; one involving two VMs. We refer to each scenario as Scenario 1and Scenario 2.

VirtualBox Network Information:

Types of networks:

Another concept that can be used with IP networks (and that is supported by VirtualBox) is port forwarding. Several variants of the idea, but basically the Host can be told that for any packets that arrive with a destination IP address matching the Host's external facing IP address and with a specific destination port, this packet should not be forwarded to the Host, instead, it should be forward to a different socket endpoint. When setting up port forwarding, you specify the matching destination IP address and port and the new destination address and port. The simple case is when the new destination IP address is the Host's IP address, but packets with specific ports are 'forwarded' to a new destination IP and port. NAT generally does not allow 'unsolicited' outside connections (in other words, NAT works only on IP flows that originate from the private side. NAT, therefore, supports inside-to-outside connectivity. Port forwarding is a widely used technique that allows unsolicited outside-to-inside access.

These various choices of networks allows VirtualBox to support VMs that are happy being 1)disconnected from any external network; 2)secure outside-to-inside access with NAT; 3)unsolicited outside-to-inside access with Bridge networking; 4)more restrictive unsolicited outside-to-inside access with NAT and port forwarding.

 

Also, review outside material to make sure the following makes sense:

Scenario 1 - one VM

There are two options: the default NAT and bridge mode.

 

NAT:

L1 is the link from Host to the outside (campus wifi ) and L2 is the virtual network where the details can vary depending on how we configure the VM. Our starting point is to have L2 be a simple ethernet link as seen by VM1.The simplest approach is to use the default setup of NAT. By default, VirtualBox sets the the default network setup for VM1 will be 'NAT' (Note.....not NATNetwork). See Section 6.2 of the Manual.

Network--L1----Host--Link2-L2--VM1

By default, the Host OS VM facing NIC will be assigned an IP address of 10.0.2.2, although you won't see this IP if you issue ifconfig at the HostOS. The VM (in all VMs ) are assigned 10.0.2.15.

To allow outside to inside access, port forwarding is used.

It is very easy to use port forwarding with NAT.Issue the following from your Host OS. The first allows ssh access to your VM from a machine on the campus network.

Bridge Mode: Modify the VM machine configuration to use Bridge Mode for the type of network on the interface that will be used to provide connectivity to the outside world. Modify the VM (actually this would be the default settings in the VM OS) to used DHCP to obtain its IP information. When the VM boots it interacts with a DHCP server that should be in operation in the outside network. For a campus environment, the VM is allocated an IP address in the same way as the Host OS's interface to the campus network. The address will be different than that allocated to the Host OS. The campus wifi network (eduroam) is a bit problematic- you might need to connect your laptop to a campus ethernet. The easiest to get working is usually in your home environment where you have control over the WiFi AP.

Scenario 2 - Two VMs

Network ----Host -----VM1----VM2

We idenfity the following assumptions for this scenario:

We describe the setup in the following four steps. Step

 

Step 1: VM1 to Internet with NAT network

This is the 'one VM' setup described above.

Internet ----host os ------'hard wired link'---- VM1

------------ ....10.0.2.2 .................................10.0.2.15

VirtualBox setups up a 'hard wired link' allowing a VM (any number) to communicate through the Host using NAT. Don't be alarmed when you see all VMs are assigned an IP address of the same.

The VM will show a NAT network (Settings --- Networks ). Click Advanced and it will show the MAC address. VirtualBox uses a somewhat strange network scenario-it assigns all VMs to use NAT with an IP of 10.0.2.15.

To complete step 1, validate the network is as expected by:

Explanation: Host OS is performing NAT on behalf of flows intiated by VM1. Let's say our Host OS has an IP of 172.23.0.1. When VM1 issues a ping to a machine like netlab.cs.clemson.edu, the netlab host will think its interacting with a host with a source IP of the Host OS's IP address to the outside world.....when really the source is VM1!!

Step 2. Setup Host only Network or an internal network between VMs

Next, let's add VM2 and connect VM1-VM2 using a private network

Internet ----host os ------'hard wire'---- VM1 ----- private 192.168.1/24 ---- VM2

Turn off all VMs. In VirtualBox Manager, File --- Preferences---Network create a Host only network. Double click...and we see the default address of 192.168.56.1. I suggest turning DHCP OFF.

Or....instead of Host only, create an internal network.

Go to VM1 settings --- Network --- And should see Adapter 1 and Adapter 2 (NAT and Host Only). Double check in your VM, select Devices --- Network --- Settings : you should see Adapter 1 and 2.

Next, we need to configure Linux to use the second adapter. Got to Linux System Settings and Network. You should see 2 wired adapters: The interface for connecting to the outside world - it likely shows 10.0.2.15 for the IP, subnet of 255.255.255.0 and GW of 10.0.2.2. . Make sure to use DHCP for the Method (addressing). This setting will cause the IP host to include just one default route in the route table (check with 'netstat -rn' or 'ip route show' ).

The other interface, select Manual, Add a new entry to specify an IP of 192.168.2.1, subnet of 255.255.255.0 but Don't specify a GW! Go to routes, and select the button that says 'Use this connection only for resources on its network.' This is necessary to ensure that only 1 default route is set up.

To double check, on a terminal on VM1, issue ifconfig. You should now see both adapters with the IP addresses (10.0.2.15 and 192.168.2.1).

Note that the 'internal network' is even easier- no need to create a Host only network in Preferences....in fact you might need to remove any Host only networks defined that you are not using.

Step 3. Complete VM2 setup.

------------VM1-----------VM2

....................192.168.2.1 ----192.168.2.100

(Note: you can use any network addressing scheme you like....does not HAVE to be 192...Any private addresses will work. )

 

While powered off, go to settings and Network and disable (deselect) the NAT network adapter (in my case it is Adapter 1). But Adapter 2 should still indicate 'enable' and Host Only.

Start VM2. Issue an ifconfig. Repeat the steps above when we configured VM1's Linux Network Manager to use the Host Only adapter, assign a static IP 192.168.2.100. Make the default router be VM1's 192.168. address.

From VM2, you should be able to ping 192.168. but nothing beyond VM1. So a ping google.com will fail.

Step 4. Configure VM1 to serve as a NAT router

This is the magic step...setting up VM1 to allow VM2 to connect with the outside world. If successful, the IP addresses are as shown below. NAT is in affect at two locations:

Outside Network ---HostOS-------------VM1-----------VM2

........................................10.0.2.2 .....10.0.2.15 192.168.2.1 ------ 192.168.2.100

 

 

Our Host OS continues to operate NAT for all traffic initiated by our VMs. Additionally, VM1 operates NAT on behalf of traffic initiated by VM2.

 

 

Problems/Troubleshooting:

If you have problems:

 

 

Additional VirtualBox Items

The following operations might come in handy

 

5/25/2017