When I build an environment in my lab I need it to be as close to production reality as it can be. When I am at a client I need to be certain of how the compute, network, and storage resources are going to interact. From a compute perspective this is easy to simulate in a lab environment. vSphere was made to do it. Things get trickier when trying to test storage and even more so with network hardware.
Storage has become easier in the last couple years with several Virtual Appliances available from EMC, NetApp, HP, and IBM that emulate their hardware cousins rather well. Block can still be an issue and FiberChannel is right out, but you can get pretty close.
Network is another story. Their are plenty of great free virtual appliances and programs that allow you setup complex routed networks in a virtual lab. The problem is that my clients don’t use these in production. Ever. I would hazard a guess that 90% of my clients run Cisco gear. With the Nexus 1K switching is taken care of, but what about routers?
With a little ingenuity and google.com I’ve solve this problem. Although not quite them same, I’ve managed to create a virtual machine to simulate one of the routers I see often, the Cisco 3725.
How It Works
GNS3 is a useful app that folks studying for Cisco certifications have used for years to create simulated networks to practice labs. It is a graphical front end that runs a program called Dynamips that emulates Cisco hardware and can run certain IOS images. When installed on Linux, Dynamips also has a hypervisor mode that can be managed with another program called Dynagen allowing you to run a headless virtual IOS image.
Dynamips also allows you to bind Linux ethernet interfaces directly to the IOS image. This is key.
By running a Dynamips and a Cisco 3725 IOS image on a virtual machine with multiple NICs and Ubuntu Server 12.04 LTS you are able to simulate the real thing. You can telnet to the console of the router, configure as normal, connect the vNICs to multiple virtual networks and presto you are now able to use all the advanced Cisco features in your virtual lab.
The Base Virtual Machine
Create a VM with this hardware configuration:
Network Adapter 1 will be associated to the IP of the underlying Ubuntu server as well as the console port of the Router. Adapters 2,3,4 and 5 will be bound to FastEthernet 0/0,0/1, 1/0, and 2/0 of the Router, respectively. This will result in simulating a router that has 4 ethernet ports, 2 onboard, and 2 1-port NM-1FE-TX Network Modules.
Install Ubuntu Server 12.04 LTS 64-bit. Add the SSH Server package during the install and assign a static IP to eth0. Accept most all the other defaults unless you decide otherwise.
Power on the machine when the install is complete.
We are now ready to build the router.
Note: I have no desire to receive a Cease and Desist order from Cisco so you will need to find a way to provide your own IOS image. The configuration here has been tested with c3725-adventerprisek9-mz.124-15.T8.image.
Building a Virtual Cisco 3725 Router
1. Connect to the Ubuntu VM via SSH.
2. Create the directory
sudo mkdir /opt/dynamips
3. Change Directory to
4. Change the permissions on
sudo chmod -R 755 /opt/dynamips
5. Download the dynagen package.
sudo wget 'http://sourceforge.net/projects/dyna-gen/files/dynagen%20source%20_%20Linux/dynagen%200.11.0/dynagen-0.11.0.tar.gz/download'
6. Uncompress the package.
sudo tar -xzf download
7. Download dynamips.
sudo wget http://www.ipflow.utc.fr/dynamips/dynamips-0.2.8-RC2-amd64.bin
8. Change permissions on dynamips.
sudo chmod 755 dynamips-0.2.8-RC2-amd64.bin
9. Change Directory to /usr/bin.
10. Create a symbolic link for dynamips.
sudo ln -s /opt/dynamips/dynamips-0.2.8-RC2-amd64.bin dynamips
11. Create a symbolic link for dynagen and update the link database.
sudo ln -s /opt/dynamips/dynagen-0.11.0/dynagen dynagen
12. Create the following directories in
/opt/dynamips: images, working, and vmware
sudo mkdir /opt/dynamips/images sudo mkdir /opt/dynamips/working sudo mkdir /opt/dynamips/vmware
13. Download this file: vbyron-vm-router-files.zip
14. Extract the archive.
15. Upload your Cisco IOS image and the 4 files from the archive to the guest VM using WinSCP.
16. Copy the image to the folder
sudo cp imagename /opt/dynamips/images
17. Change Directory to
/opt/dynamips/vmware and create a sub-directory named
cd /opt/dynamips/vmware sudo mkdir ./initial.configs
18. Copy the 2 config files to
cd ~ sudo cp R1.initial.config.* /opt/dynamips/vmware/initial.configs/
sudo cp vmware.net /opt/dynamips/vmware/
20. Bring interfaces eth1, eth2, eth3, and eth4 up.
sudo ifconfig eth1 up sudo ifconfig eth2 up sudo ifconfig eth3 up sudo ifconfig eth4 up
22. This will launch the Dynagen management console and start the Router. Wait a few minutes for the Router to boot. The CPU will spike. This is normal.
23. To calm the CPU down run
idlepc get R1
idlepc get R1
24. Enter the number of the line that has an asterix.
25. Save the value to the database.
idlepc save R1 db
26. Restart the Router.
stop R1 start R1
27. Wait for the Router to boot. The CPU should not spike this time.
28. Now open a telnet session in the client of your choice. The IP address, port 2001 assigned to eth0 will be the console port.
You now have a fully functional 4 port Cisco 3725 router running as a guest in vSphere. Configure it just as you would on a physical 3725.
Connect VMs to the networks you create on the Router and use the Router’s ports on the network as the default gateway. Traffic should route as expected.