So, I wanted to try some stuff on a local network by making my very own private servers ftp, samba, Apache and others. The only problem was I only had a single laptop! So, even if I would have made all these servers on my laptop I wouldn’t have been able to test them effectively, not to mention exposing myself to other security implications. Then I thought why not try some Virtualization tools. When it comes to Virtualization I always prefer Virtualbox as it is very easy to use.
There are three ways by which you create a virtual network with Virtualbox:
#1) Set your Virtual Machine’s Network Adapter to Bridged Mode. In this case your virtual machine will fetch an IP address directly from the router. Let’s say your router has as an IP 184.108.40.206 and your physical machine gets an IP 192.168.1.2 then your VMs will get IP 192.168.1.3 and so on.
#2) Set your Virtual Machine’s Network Adapter to Internal Networking Mode. This will create a network between all of your VMs that are using the same internal network.
However, VirtualBox doesn’t provide any GUI tools to configure any additional settings for this mode as you will find for Host-only network. So, either you have to set static addresses for all your VMs or you can add a DHCP server for your internal network by typing the following line in a terminal:
VBoxManage dhcpserver add --netname intnet0 --ip 192.168.66.1 --netmask 255.255.255.0 --lowerip 192.168.66.2 --upperip 192.168.66.255 --enable
If you want to remove the DHCP server then type the following line in a terminal:
VBoxManage dhcpserver remove --netname intnet0
#3) Create a Host-only network by going to VirtualBox Managers Preferences. Go to File ->Preferences -> Network. You can configure all of the settings for Host-only network from here. If you want your VM’s to fetch an IP automatically then enable the DHCP server as well. And set your Virtual Machine’s Network Adapter to Host-only network.
If you want you can use the previous commands here also, just change the name with the host-only network name. The command would look like this:
VBoxManage dhcpserver add --netname vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.2 --upperip 192.168.56.255 --enable
In this case not only will the VMs be the part of that network but your Physical machine will also be a part of that network. Your Physical machine will get an additional network interface that usually goes by vboxnet’x’ where ‘x’ can be any number starting from 0 depending on the number of host-only networks that you have.
Well, now that you have your network setup, have fun with it !!:)