Virtual Network

One day you might fink, just like me, how to create a virtual network on my virtual machines, using a virtual box. Sounds crazy, but hey not only web development is interesting. I’m curious and have a lot of fun to discover new things. If you also want to know, how to build your home network without one single cable enjoy this article.

Step one: Installing Virtual Box

To build virtual machines and virtual networks you need to install a virtual box first. I wrote about this article called: Virtual Linux Server when I build a Linux server on a virtual machine, but installing a virtual box is the same.

The major difference is that now I going to build three machines: Windows Server, Windows 10, and Debian. Windows Server in trial 90 days mode you can download from Microsoft page. Windows 10 in developer’s mode also. Debian is free Linux distribution. You need to download the iso image, and then install it on your virtual box.

One more information before you start. You need to have about 16 GB RAM to be able to run three virtual machines which good reactivity. What’s more, I use Linux System as a host, because on Windows virtual machine crashed from time to time when I fired up several virtual machines at this same time.


Step two: virtual network

First of all, you need to configure the virtual box set for the inside network. In setting options open tab network and from the opening list choose Internal Networking. Leave the default name of this network, or change to this same name for all virtual machines.

Now, you can run your virtual machines. When doing so, you need to assign an individual IP address to each of them, because no DHCP server works in your network.

On a Windows machine you need to open Network and Internet -> Network connections then point your network card by courser and hit the right button on the mouse. Select properties and then Internet Protocol Version 4.

Settings virtual network on Windows Machine

Select properties and then check “Use the following IP address:” and fill IP address and subnet mask just like on the picture, or made your own IP address, but from this same range.

Set static IP address to virtual network on Windows Machine

Hit OK, and then close properties windows. Again, point to the network icon by courser, click the right mouse button, and disable the card, after a moment turn on it again. It’s necessary to restart the card because they won’t change the IP address if you don’t reset it.

Great, one machine is almost ready. But now it’s a tricky thing. You need to disable Windows Defender. If not, other machines won’t be able to communicate with this one. Wat’s worse, this machine won’t communicate with others also.

Go to system and security options, then Windows Defender Firewall and disable it.

Windows defender disable for virtual network purpose.

Do this same on another windows machine. On a Linux machine, you can also set up a connection via network windows. Select network, then properties, and grant new unique IP address and this same mask. Just like on the window below.

Linux IP address configuration in virtual network
Yes, it’s polish language, but in English it’s looks that same)

If everything works fine, you should have the ability to communicate between machines using the ping command. Now You are a master virtual network commander.

DHCP Server in Virtual Network

One of our machines is Windows Server. It’s because, now I’m going to show you, how to build a DHCP server and connect other machines to the internet via server routing.

But before, we do that, you need to switch off your server machine, and add another network card in the virtual box setting manager. This card should be set as NAT. When you have two networks card added to the Virtual box configuration you can start this machine again.

Let’s start with the DHCP server. In the first step, look into Local Server Properties. You should see two cards. I called it WAN and LAN to simplest understand with is my internetwork and which is connected to the internet.

Windows server virtual network properties window.

From the dashboard choose “Add roles and features” to add a new role.

Windows server dashboard screen

Click “next” three times, and you will see a window with which roles to select. Check “DHCP Server” role. A new window will appear. Click Add features. Again, click Next until the Install button will be available. Click Install and Server DHCP will install.

After install finished, you need to Authorized the DHCP server. Click on the blue link “Complete DHCP configuration”

Windows Server DHCP authorized step.

From the appeared window click Commit. Security group added. You can close the installation windows. From the header menu chose the tool and then DHCP. Tool window appears. From the left column expand the server tree. Right-click on IPv4 and from the menu choose “New Scope”. Configuration wizard appears. Add scope name, and description (a description is an option). Click next and set scope from start IP to end IP and set mask for example:

The next step is to set exclusion, we don’t need it so just click next. Then you can set a time for IP address reservation. I set 30 days.

Address reservation time for machines in virtual network

After this click next and use the default option “Yes, I want to configure these options now”. Clicks next. In router (default gateway) add your server address. In our case 172.16.0.1 then in the next window you set the Parent domain we use “virtual.network” and DNS server let’s say 8.8.8.8 because we don’t have any on the local server.

DNS configuration on windows server in virtual network

Server WINS you can skip by click Next and in last windows finally click next leaving selected options.

Your DHCP server should work fine. Let’s try it. On windows virtual machine open Network and Internet -> Network connections then point your network card by courser and hit the right button on the mouse. Select properties and then Internet Protocol Version 4 and then use Obtain an automatically for IP address and DNS.

After a few moments, when the connection appears you can check it’s fine in console mode using ipconfig command. On Linux machine also change static IP to automatically granted.

Routing services on Virtual Network

The last step is connecting our virtual machines to the Internet. We can do this using Routing services on Windows Server.

Open Server Manager Dashboard, and just like before click “Add roles and features”. After skipping the first windows from “Select server roles” check “Remote Access” and click Next. No features needed, so click next, and next window also next. From “Select the role services to install or Remote Access” select “Routing”.

Set routing services on Windows Serwer in virtual network

“DirectAccess and VPN (RAS) will be added automatically just like Web Server. Just click next, Web Server will be needed to set up the web page if you will do so. In the last window just click Install. After installation complete, from the server manager dashboard click tools and select “Routing and Remote Access”.

Routing tool on Windows Server

In the appeared window right-click on the server name and click on “Configure and Enable Routing and Remote Access”. Wizard will appear. Click next and from Configuration, list chooses “Network address translation (NAT)”. Then the wizard will ask to point network interface that is connected to the Internet. I called this interface WAN and point to it.

NAT Internet connection setup in virtual network.

Click next and finish.

Cool, your virtual network has access to the real Internet. That’s all that I wanted to show you in this article. But still, there is one more question.

What can I do with Virtual Network?

At this moment I see two options: test security on your website in a safe environment and test tools like Docker. For web pages purpose, you already have a web server installed. You just need to configure it. If you want to test software like Docker you will need to install it first, but sometimes when you curious about how something works, and want to test its safety it’s better to do this in this way.

Krzysztof NyrekVirtual Network