VirtualBox is amazing piece of virtualization software. It is a cross-platform, free and open source software. For all my development and testing purpose, I use the VirtualBox maximum where ever it is possible. Today I thought to share some of my virtualization experience from my development environment that would probably help some others who are studying or struggling to setup some sort of networks tasks. Let’s start..
Ok, let’s make our plan first. We will be creating a simple network alongside the Oracle Virtual Box having one gateway server and a client. Gateway is created with the Linux CentOS 6 Server and the client is with Microsoft Windows 7.
- Configure VirtualBox to have the Virtual Network with desired IP range and subnet
- Installing two OSs to simulate the network connectivity between them
- Installing Windows 7 within VirtualBox
- Installing a Linux OS (CentOS) within VirtualBox
- Configure and finalize the network setup within the installed OSs
- Gateway configuration in CentOS
- Client network configuration in Windows OS
- Testing the connectivity of installed OSs within the created network
General Configuration in VirtualBox
This guide assumes that you have already installed Oracle Virtual box in your PC/Laptop. If you do not have done already, please download and install it from here that is suitable for your version of OS. You can rather follow this link to learn more about installation.
- Open Oracle VM VirtualBox Manager
- Go to menu File->Preferences
- Click on the “Network” tab on the left pane
- Click on the “NAT Networks” tab on top bar
- Click on “Add new NAT Network” image icon on the right toolset
- Select the newly added NAT Network, and click on the “Edits selected NAT Networks” image icon on the right toolset
- Make sure “Enable Network” is ticked
- Make sure “Supports DHCP” is ticked
- Modify the IP ranges if it is necessary
- Press ok to accept the changes
Create a new Virtual Machine for Gateway
- Open Oracle VM VirtualBox Manager
- Go to menu Machine->New..
- Update it as in the above screenshot (Give any name for “Name”, choose type “LInux” and select version “Red Hat (64-bit)”) and then Click “Next“
- Assign memory to at-least 1024 MB in the memory size page and click “Next“
- Choose “Create a virtual hard disk now” option and click “Create“
- In the Hard disk file type page, choose “VDI (VirtualBox Disk Image)” and click “Next”
- Choose either “Dynamically allocated” or “Fixed size” on the “Storage on physical disk” page and click “Next” (If you are not sure, choose “Dynamically allocated”)
- Click “Create” with the default values on “File location and size” page unless you have custom settings.
Create a new Virtual Machine for client (Windows 7)
Follow the same step as above (Create a new Virtual Machine for Gateway) except in the step 2 and 3. Follow the below screenshot and the values.
Name: WIndows7, Type: Microsoft Windows, Version: Windows7 (64-bit) or (32-bit)
Memory Size: 512 (this is default value, you can increase if you have enough disk space in your PC/Laptop)
File Location and Size: 25 GB (this is default value, you can adjust this to comfort your system disk space)
Yes, Now both machines are ready for go ahead.
Configuring Networks and other properties
Now the remaining part is adding network interface to machines and tune other basic properties. Do this by selecting the each machine and clicking on menu Machine->Settings or clicking the Setting icon on the top toolbar.
In the “Settings” dialog box, left sidebar, click on the “Network” menu. Then make sure the “Adapter 1” is selected in top tabular menu. Make sure the “Enable Network Adapter” check box is ticked and choose the “NAT Network” in the “Attached to” select box, then select the network in the below select box which we created in earlier step. Follow the screenshot below.
Attach installation images
There are two ways you can start the installation, using an installation media or an image such as (ISO Image). If you have installation CDs, just start by inserting the CD into the CD drive. Otherwise, you should attach the installation image to the storage in the virtual machines.
If you do not have Linux CentOS installation media, download the ISO image from this link. Download CentOS (choose an appropriate mirror). And keep your Windows 7 installation media ready, if you do not have one, try to download at-least one that is trial.
How do we attach the installation media?
Repeat the steps we learnt above to open the “Settings” dialog box.
- Click on “Storage” menu in the left sidebar
- Click on the “Empty” CD icon below the Storage tree.
- Then, click on the CD icon at the right side to choose a CD Image.
- Choose the downloaded ISO image if you have one, then click OK to close the dialog boxes.
You can follow the same procedure to choose Disk image for both of the virtual machines. Or insert the installation CD if you have one.
This is simple step as you just click “Start” along with the machine selected in the top tool bar. Just do it for both machines one by one and complete the usual installation procedure for them.
Well, Now assume we have setup both machines and they are ready for network configurations.
Configure the Gateway
First, let us configure the gateway.
Open up the terminal of CentOs and fire the following command.
If you are familiar with
VI editor use the below script as it is or else replace the editor with the one you are familiar with. For example
i in keyboard to change to
INSERT mode and enter following detail into. (If the file already has content, Press
Escape and then keep pressing the
d in your keyboard until it deletes the all lines. Then start the insert mode by pressing the
i in your keyboard)
Escape in your keyboard, press
Enter. It will save and exit the changes. Now let us restart the network with following command.
Once the restart process successfully completed, check your network configuration by hitting the following command on your command line.
Configure the Client (Windows 7)
- Open “Network and Sharing Center“.
- Click on “Change adapter settings” on left side bar menu
- Right click on “Local Area Connection” and click “Properties” menu item
- In the “Local Area Connection Properties” dialog box, Click on “Internet Protocol Version 4 (TCP/IPv4)” item under the “This connection uses the following items” list
- Click “Properties” button below that
- Select the option “Use the following IP address“
- Set the IP Address to 192.168.100.2 (use any IP in the subnet that is not equal to 192.168.100.1 which we set as gateway IP)
- Fill subnet as 255.255.255.0.
- Fill default gateway as 192.168.100.1.
(Follow the following screenshot for the graphical guide)
So far, we have completed all the steps for a basic local network setup. Now our client has connectivity to the server. For testing the connectivity, open up the terminal in windows, and ping the gateway IP.
- Click windows start button
- Enter “CMD” in search box and hit enter, (You will get the windows command line)
- Type “ping 192.168.100.1” and hit enter,
(Look at the following screenshot for the result)
Congratulation, your local network setup is complete. In the next post we will be looking at how we can provide DHCP IP to the clients with the setup Gateway. Right now, the clients will not have internet access. We will be looking at the configuration in Gateway to provide internet access to the clients. I will try to complete those guide within coming week. Do not forget to share your feedback. Thank you.