02 Virtual Network Setup
02 Virtual Network Setup
Introduction
Virtual Machines have been with us for quite a few years now. There are lots of different
ways to create a virtual network out there, in this labsheet we will explore VMware Player.
VMware is one of the oldest (if not the oldest) Virtualization pieces of software around, their
latest incarnation is the VMware Player which is free and simple enough to introduce you to
the concept of Virtualization without the complexities that come with other software packages
like ESX Server or KVM. In this labsheet we will build a small virtual network and see how we
can connect VMs to each other.
https://my.vmware.com/en/web/vmware/downloads/details?downloadGroup=PLAYER-
1600&productId=1039&rPId=51984
Building a VM
You now need to build your CentOS client in the Virtual machine. To do this you will
need to create it first (the equivalent of putting the hardware together) and you will now need
to have the CentOS iso file so download it here:
http://isoredirect.centos.org/centos/7/isos/x86_64/
Click on Create a new virtual machine. Use ISO image, click Browse and find your CentOS
iso. It should say “CentOS 7 64-bit detected”. Click Next and leave the OS to Linux and click
Next. Give the VM a name of vPrometheus0 and click Next. Set the HDD size to 10Gbytes
and in the next page select customize hardware. Set the RAM to 1GB (set it to 2GB if you
have more than 16GB on your system in total or if you are working remotely in the lab), set the
network adapter to NAT and click close and Finish. Close the next message and Select
Download and Install the VMware Tools Software Update it proposes. The VM should now
Boot into the Installation.
Choose Install CentOS 7. If you need to escape the cursor from inside the VM press alt-ctrl.
Choose Language English (United Kingdom) and continue. In Software selection choose
GNOME Desktop and click Done. In Network and Hostname set the Hostname to
vPrometheus0.netlab.ee.port.ac.uk and click Done. You are now ready to Begin
Installation.
While the installation is progressing set the Root Password to localhost1 and create a user
called DoNotUseMe. It will restart once and you must accept the License Agreement and let
it reboot again and you are done!
To build the rest of the network, according to our network diagram, we need 2 more of
those VMs. However you do not have to go through the hassle of repeating this whole
procedure, you can just clone the existing VM, rename it and use it! Shut down the VM, go into
/root/vmware and find the folder with the name of the VM. right click on it and copy and then
right click in the empty space and paste. This should now create a VM (copy). Rename this
folder into vPrometheus1. Now go to a terminal and type vmplayer again to start another
instance of the software. Go File - Open a Virtual Machine, select your new VM choose the
.vmx file and click open. Edit the VM settings and rename it (it's in the options tab). Now Play
the VM. Select "I copied it", ignore the VMTools update message and let it boot. Log in,
rename it with the hostname command, reboot again and you are done! Repeat the Cloning
process again for vPrometheus2. You now have 2 more VMs but when you go into their
terminals they are still called vPrometheus0! How can you change that? Research “how to
rename a Redhat computer” and do it.
On Moodle you will find a little script called vm_subnet. Download it and save it in your
root folder. Edit it with gedit or any other editor that suits you. We want it to start and configure
vmnet0 and vmnet1 and we want it to start just as processes, vmnet2 and vmnet3. Change
the networking information in the script to match your network diagram and save it. You then
need to sort out the permissions for it so chmod 777 vm_subnet in a terminal. Now you will
need to shut down vmnet1 as was started by the software and its corresponding dhcp server.
ps -ef | grep vmnet will give you a listing of all vmnet related processes so you can now kill
the 2 processes associated with vmnet1. Now run the script with ./vm_subnet. Type ifconfig
now. What has changed? Type ps –ef | grep vmnet now. What do you see?
We now need to setup the Virtual network cards. To do this you need to have the option
in your VMs to use more than one Host-Only network cards. In order to do this we have a
custom made script called fix-vmnet-dev. Download it, save it into each of the VM folders, run
it for each folder (on Prometheus NOT inside the VMs) and then go to the virtual machine
settings of each of your VMs. What do you see there? Configure v0 for one network card
connected to vmnet0, configure v1 for 2 network cards connected to vmnet1 and vmnet2 and
finally configure v2 for one network card connected to vmnet2. Now boot the VMs you've
already built and make the appropriate changes to their networking settings in there.
Remember vPrometheus1 should have 2 network cards!
After you've set everything up you should be able to ping neighbouring interfaces so
from VM0 to the host, from VM1 to the host and from VM1 to VM2.
Vmnet0
148.197.30.250
fkjhflkhf
vPrometheus0
Vmnet0
148.197.30.249
fkjhflkhf
Vmnet1 Vmnet1 Vmnet2 Vmnet2
148.197.31.249 148.197.31.250 148.197.32.249 148.197.32.250
Prometheus
vPrometheus1 vPrometheus2