Setting up a local network using VirtualBox – Linux – Windows

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..

Site Plan

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.

  1. Configure VirtualBox to have the Virtual Network with desired IP range and subnet
  2. Installing two OSs to simulate the network connectivity between them
    1. Installing Windows 7 within VirtualBox
    2. Installing a Linux OS (CentOS) within VirtualBox
  3. Configure and finalize the network setup within the installed OSs
    1. Gateway configuration in CentOS
    2. Client network configuration in Windows OS
  4. 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.

  1. Open Oracle VM VirtualBox Manager
  2. Go to menu File->Preferences
    Screenshot (VirtualBox Preferences)
    Image 1 (VirtualBox Preferences)
  3. Click on the “Network” tab on the left pane
  4. Click on the “NAT Networks” tab on top bar
  5. Click on “Add new NAT Network” image icon on the right toolset
  6. Select the newly added NAT Network, and click on the “Edits selected NAT Networks” image icon on the right toolset
    Screenshot Edit nat networks
    Image 2 (Edit Nat Netwoks)
  7. Make sure “Enable Network” is ticked
  8. Make sure “Supports DHCP” is ticked
  9. Modify the IP ranges if it is necessary
  10. Press ok to accept the changes

Create a new Virtual Machine for Gateway

  1. Open Oracle VM VirtualBox Manager
  2. Go to menu Machine->New..
    Screenshot - Create new virtual machine for gateway
    Image 3 (Create new virtual machne for gateway setup)
  3. 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
  4. Assign memory to at-least 1024 MB in the memory size page and click “Next
  5. Choose “Create a virtual hard disk now” option and click “Create
  6. In the Hard disk file type page, choose “VDI (VirtualBox Disk Image)” and click “Next”
  7. 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”)
  8. 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)

Screenshot- create new virtual machine windows 7
Image 4 (Create a new virtual machine for Windows client)

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.

screenshot - both machines are ready for intallation
Image 5 (VirtualBox with windows and linux machines)

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.

Image 6 (Network configuration)

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.

  1. Click on “Storage” menu in the left sidebar
  2. Click on the “Empty” CD icon below the Storage tree.
    Image 7 (Select bootable image)
  3. Then, click on the CD icon at the right side to choose a CD Image.
    Image 8 (Choose Virtual Optical Disk File..)
  4. 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.

Image 9 (Start button)

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 nano

Press the 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)

Press Escape in your keyboard, press :, press x and 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)

  1. Open “Network and Sharing Center“.
  2. Click on “Change adapter settings” on left side bar menu
  3. Right click on “Local Area Connection” and click “Properties” menu item
  4. 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
  5. Click “Properties” button below that
  6. Select the option “Use the following IP address
  7. Set the IP Address to (use any IP in the subnet that is not equal to which we set as gateway IP)
  8. Fill subnet as
  9. Fill default gateway as
    (Follow the following screenshot for the graphical guide)
Virtualbox - Windows 7 Network Guide
Image 10 (Windows network setup)

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” and hit enter,
    (Look at the following screenshot for the result)
Ping Gateway from Windows command line
Image 11 (Ping Gateway from Windows command line)

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.

One thought on “Setting up a local network using VirtualBox – Linux – Windows

Leave a Reply

Your email address will not be published. Required fields are marked *


Please wrap all source codes with [code][/code] tags.

This site uses Akismet to reduce spam. Learn how your comment data is processed.