Recently I had to set up a network experiment using three nodes, and I had only one machine, and I was able to successfully set this up using three VMs on VMWare Workstation. This is how I did it.
I had to set up the following:
- Content server: public IP address with Apache installed
- NetServ node: a router with one public IP and one private IP
- Client: Private IP, connected through the NetServ node gateway
I need the client to access the outside world only through the NetServ router.
First, I downloaded a Fedora 10 VMWare image from thoughtpolice.co.uk and configured it as I needed. Then I made three copies of it.
[Note about clean-start: When copying the VMWare images to create clones, make sure to shutdown the images first before copying. The reason is that when you copy and start the clone, VMWare changes the MAC address and other settings, and you need to clean-start the VM to get the new MAC address and other settings to apply.]
I then created a few virtual network configurations to get my network topology right. A screenshot of the Virtual Network Editor is below.
- I have three physical network adapters. I configured each of them to map to one particular VMNet. VMNet0 is bridged to the first physical adapter (that is my host machine).
- The two other VMNets – which are bridged to the physical adapters – are the ones used by the public network adapters for the Content Server and the NetServ node.
- For the private network, I created host-only VMNet with DHCP service, which basically provides a private network.
- The private network adapter for the NetServ node and the Client are mapped to this VMNet.
So far, so good. Boot up the nodes and they should get correct IP addresses and:
- Content Server and Netserv Node can connect to the public Internet.
- Client can only ping the Netserv node’s private IP address.
Now to get the full network topology working.
For this, we need to allow NetServ node to run as a router and a DNS server. Here is how to do so (all as root):
Now, on the client machine, you need to set up the default gateway to be the NetServ router:
route add default gw NETSERV_IP_ADDR eth0
[UPDATE Sep 24 2010] On the client machine, you also need to:
sudo vi /etc/resolv.conf
and add the NetServ/gateway machine as the default DNS server.
And that’s it : you should have a complete network topology up and running! Try a few pings and opening a few websites, and it should all work!