Installing Dynamips & Dynagen on Ubuntu with Quad NIC’s to Real Switches (Start From Here)

by Stamati Panagiotaras (Panos) CCIE 17823

I’ve been using dynamips for Linux for the past 7 years now and i thought i would share with you my installation to help you set this up yourself.  The advantages of this installation is cost.  Firstly i do not have 9 extra routers consuming electricity but also the cost of buying all the separate routers will not be cheap!!  Also installing this on linux really does make dynamips/dynagen run much faster and more reliably compared to Windows.

Full Installation including cabling and how to console

Here i’m going to try and show you how i setup an Internetwork Expert CCIE R&S Lab using Quad NIC’s to real switches on Ubuntu Precise 12.04 LTS.

I have 1 Cisco 3750, 1 Cisco 3560 & 2 Cisco 3550’s

I bought my serial to USB cables (used to console from my Ubuntu box to the ‘real switches’) from this company.

http://www.tronisoft.com/cat_usbtoserial.php

I decided they were the best choice after using so many others in the past and having been faulty or fake.

I custom made my server, which i bought in parts from ebay.  You just need to make sure you have enough PCI ports (if you’re using Quad PCI NIC’s.) when looking for a motherboard and it should be able to run at least dual core with 4gb memory.  This will be our  9 virtual Routers for the Internetwork Expert Labs.

I bought 3 Quad PCI NIC’s. – D-Link DFE-580TX –

4 Console Cables (These are connected to the USB to Serial Cables i bought from Tronisoft)

I bought 20 0.5m Cat 5 Patch Cables (Switch to Switch)

and

11 1M Cat 5 Patch Cables (Switch to D-Link DFE-580TX)  – They were 90p a cable.

Here’s how i set mine up.

Cabling the Switches to Your PC/Server

Add the Quad NIC’s to your first 3 PCI slots on your Motherboard.

Cable your switches as shown in the topology below.

When connecting from your Quad NICs to your Switches take note of how the ine.net file is configured so you can see how the ports are binded.

I’ll explain:-

For example in the ine.net file (full configuration is further down the page)

R1’s ine.net connfiguration says:-

F0/0 = NIO_linux_eth:eth1

That means the 1st Quad NIC port is connected to R1’s F0/0

F0/0 = NIO_linux_eth:eth2

That means the 2nd Quad NIC port is connected to R2’s FO/O

F0/0 = NIO_linux_eth:eth3

F0/1 = NIO_linux_eth:eth4

So on R3’s f0/0 is connected to the 3rd NIC and F0/1 is connected to the 4th…

etc..

Dynamips Installation

Install Dynamips & Dynagen:

Create a new directory for dynamips

sudo mkdir /opt/dynamips

Change to dynamips directory

cd /opt/dynamips

Change the folder permissions

sudo chmod -R 755 /opt/dynamips

http://dynagen.org/interim_builds/index.html

Download latest dynagen software from the link above

Extract the tarball by right clicking the file and extract to.

Now move the extracted folder to /opt/dynamips

Change to /opt/dynamips directory

cd /opt/dynamips

Download Dynamips from Dynamips blog

sudo wget http://www.ipflow.utc.fr/dynamips/dynamips-0.2.8-RC2-amd64.bin

Or for 32bit

sudo wget http://www.ipflow.utc.fr/dynamips/dynamips-0.2.8-RC2-x86.bin

Use chmod to change permission (You may not have to do this, but just in case)

For 64bit

sudo chmod 755 dynamips-0.2.8-RC2-amd64.bin

Or for 32bit

sudo chmod 755 dynamips-0.2.8-RC2-x86.bin

Go to /usr/bin to create a symbolic link for dynagen

cd /usr/bin

For 64bit

sudo ln -s /opt/dynamips/dynamips-0.2.8-RC2-amd64.bin dynamips

Or for 32bit

sudo ln -s /opt/dynamips/dynamips-0.2.8-RC2-x86.bin dynamips

Now a dynagen link

sudo ln -s /opt/dynamips/dynagen-0.11.0/dynagen dynagen
sudo updatedb

Go to INE Website and download their dynagen configs

INE Topologies for Dynagen

Extract the file and move it to your /opt/dynamips folder

Create a directory for the cisco routers image

sudo mkdir /opt/dynamips/images

Put your  cisco IOS image in /opt/dynamips/images folder.

Add a working directory

sudo mkdir /opt/dynamips/working

Create a 'New Empty Document'. Right click on the desktop & copy and paste 
the text below and save as ine.net.  Save this file in your /opt/dynamips/internetworkexpert folder

##############################################################################################

#

# Internetwork Expert Routing & Switching topology Version 5.0 mappings for dynamips/dynagen on Mac OS X

#

#

# For more information:

# Dynamips: http://www.ipflow.utc.fr/index.php/Cisco_7200_Simulator

# Dynagen: http://dyna-gen.sourceforge.net/

# Hacki’s Forum: http://hacki.at/7200emu/index.php

# Internetwork Expert’s Forum: http://IEOC.com

#

##############################################################################################

##################################################

#

# Define global router parameters for instance 1

#

##################################################

autostart=false

[localhost:7200]

workingdir = /opt/dynamips/working

[[3725]]

# Specify 3725 IOS image on Mac OS X here:

image = /opt/dynamips/images/c3725-adventerprisek9-mz.124-15.T13.bin

ram = 256

disk0 = 0

disk1 = 0

# Choose an idlepc value from the below

mmap = true

# ghostios = true

###########################

#

# Define router instances

#

###########################

[[Router R1]]

model = 3725

console = 2001

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth1

S1/0 = FRSW 1

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R1.initial.config.txt

[[Router R2]]

model = 3725

console = 2002

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth2

S1/0 = FRSW 2

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R2.initial.config.txt

[[Router R3]]

model = 3725

console = 2003

autostart = false

slot1 = NM-4T

S1/0 = FRSW 3

S1/1 = FRSW 13

S1/2 = R1 S1/1

S1/3 = R2 S1/1

F0/0 = NIO_linux_eth:eth3

F0/1 = NIO_linux_eth:eth4

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R3.initial.config.txt

[[Router R4]]

model = 3725

console = 2004

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth5

F0/1 = NIO_linux_eth:eth6

S1/0 = FRSW 4

S1/1 = R5 S1/1

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R4.initial.config.txt

##################################################

#

# Define global router parameters for instance 2

#

##################################################

[localhost:7201]

workingdir = /opt/dynamips/working

[[3725]]

# Specify 3725 IOS image on Mac OS X here:

image = /opt/dynamips/images/c3725-adventerprisek9-mz.124-15.T13.bin

ram = 256

disk0 = 0

disk1 = 0

# Choose an idlepc value from the below

mmap = true

# ghostios = true

###########################

#

# Define router instances

#

###########################

[[Router R5]]

model = 3725

console = 2005

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth7

F0/1 = NIO_linux_eth:eth8

S1/0 = FRSW 5

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R5.initial.config.txt

[[Router R6]]

model = 3725

console = 2006

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth9

F0/1 = NIO_linux_eth:eth10

S1/0 = FRSW 6

cnfg = /opt/dynamips/internetworkexpert/initial.configs/R6.initial.config.txt

[[Router BB1]]

model = 3725

console = 2011

autostart = false

slot1 = NM-4T

S1/0 = BB3 S1/0

S1/1 = FRSW 21

cnfg = /opt/dynamips/internetworkexpert/initial.configs/BB1.initial.config.txt

[[Router BB2]]

model = 3725

console = 2012

autostart = false

F0/0 = NIO_linux_eth:eth11

cnfg = /opt/dynamips/internetworkexpert/initial.configs/BB2.initial.config.txt

[[Router BB3]]

model = 3725

console = 2013

autostart = false

slot1 = NM-4T

F0/0 = NIO_linux_eth:eth12

cnfg = /opt/dynamips/internetworkexpert/initial.configs/BB3.initial.config.txt

[[FRSW FRSW]]

# R1 to FRSW

1:102 = 2:201

1:103 = 3:301

1:113 = 13:311

1:104 = 4:401

1:105 = 5:501

# R2 to FRSW

2:203 = 3:302

2:213 = 13:312

2:204 = 4:402

2:205 = 5:502

# R3 to FRSW

3:304 = 4:403

3:305 = 5:503

13:314 = 4:413

13:315 = 5:513

# R4 to FRSW

4:405 = 5:504

# R6 to FRSW

6:51 = 21:51

6:100 = 21:100

6:101 = 21:101

6:201 = 21:201

6:301 = 21:301

6:401 = 21:401

Create a new document on your desktop and name it INE Startup.

Copy the following text:

sudo killall -w dynamips
#!/bin/bash
sudo killall -w dynamips
cd /opt/dynamips/dynagen-0.11.0
sudo dynamips -H 7200 &
sudo dynamips -H 7201 &
sudo killall -w dynamips
cd /opt/dynamips/internetworkexpert
sudo dynagen ine.net

Right click on the new file and in the permissions tab tick the execute box.`

In Ubuntu open a new terminal and type

sudo apt-get install ser2net

We now need to find which USB is attached to tty

Type:

dmesg | grep tty

Your output should look like this

[ 0.000000] console [tty0] enabled

[ 0.329797] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

[ 0.788845] 00:07: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

[ 14.407819] usb 3-1: pl2303 converter now attached to ttyUSB0

[ 14.418799] usb 3-2: pl2303 converter now attached to ttyUSB1

[ 14.430638] usb 5-1: pl2303 converter now attached to ttyUSB2

[ 14.441650] usb 5-2: pl2303 converter now attached to ttyUSB3

When adding the PL2303 serial to USB cables to your PC try and make sure you use the first USB port on your Motherboard, and connect the cisco console cables to your Switches in a logical order. For example the first console cable on the first port of your USB should be connected to Switch 1, the second to Switch 2 etc..

Now we need to edit the conf file

sudo gedit /etc/ser2net.conf

At the end of the document it will look something like this

2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner

2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner

3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner

3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner

We need to change this to
3001:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner
3002:telnet:0:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner
3003:telnet:0:/dev/ttyUSB2:9600 8DATABITS NONE 1STOPBIT banner
3004:telnet:0:/dev/ttyUSB3:9600 8DATABITS NONE 1STOPBIT banner
Now we need to install Linux tap drivers

sudo apt-get install uml-utilities

Add the tap config

sudo ifconfig tap0 128.0.0.1/30 up

Now the problem on Ubuntu is once a TAP interface is configured and the PC is rebooted, the config is lost. An easy work around is to ensure it’s configured at startup. Add the following

to /etc/rc.local:

sudo gedit /etc/rc.local

modprobe tun
tunctl
ifconfig tap0 128.0.0.1 netmask 255.255.255.252 up

Setting Up Idle-PC

If you don’t configure the idle-pc, your computers’ CPU will be 100% utilised. ‘This is because Dynamips does not know when the virtual router is idle and when it is performing useful work. The “idlepc” command performs analysis on a running image to determine the most likely points in the code that represent an idle loop in IOS. Once applied, Dynamips “sleeps” the virtual router occasionally when this idle loop is executed significantly reducing CPU consumption on the host without reducing the virtual router’s capacity to perform real work. ‘

This will help you judge which is the correct idlepc value.

Open a new terminal

and type

top

Double click the desktop executable we called ‘INE Startup’.

In the Dynagen window type

start R1

Now telnet to R1

telnet R1

Wait for the Router to fully load; Until all interfaces are up. For example

Now, switch back to the Dynagen management console, and issue an “idlepc get R1”. You will see a message that statistics are being gathered, and about 10 seconds later you should see a list of potential idlepc values:

Values that will most likely provide better results are marked with an asterisk. Select one of the values to try from the menu and press Enter. You should notice from your terminal window displaying the top CPU proceeses, the CPU utilization drops dramatically. If so, you’ve found a good idlepc value for this particular IOS image.

‘The new idlepc value will take effect dynamically. Once you’ve found a value that works, you can save it to your local idlepc database with “idlepc save R1 db”.

If your CPU usage did not drop, it’s time to try a different value. Type “idlepc show routername” to show the list of values determined earlier again, and this time select a different one.

Go to your dynagen window and type

stop R1

This stores the idlepc value for this IOS image in the file specified in dynagen.ini with the “idledb” option. The default is a file name “dynagenidledb.ini” in your $HOME or folder.

Idle-PC values are particular to an IOS image. They will be different for different IOS versions, and even for different feature sets of the same IOS version. However Idle-PC values are not particular to your host PC, operating system, or to the version of dynamips. So “dynagenidledb.ini” files from one system can be freely copied, merged, shared with others, etc.

It is possible that dynamips will not be able to find an idlepc value for an image, or that the values it does find do not work. If this happens, try repeating the process again. Or you just might be out of luck with that particular image (however running into this situation is rare.)’

To shutdown dynamips you have to simply close the window. It seems that when ever I try and kill the process, dynamips restarts in a perpetual loop.

This means that dynamips will be still running in the background but it shouldn’t affect anything else too drastically. I do advise a reboot.

Installing a multi tab console

I suggest using Gnome Connection Manager. Although this is a matter of personal preference
It’s very simple to use.

Go to Gnome Connection Manager

Download and run the deb file

This will load the deb file into the software repositary and start up ‘Ubuntu Sofware Centre.

Install and then run.

Add all the Router and Switch configurations into GCM.

Press Add

Correct the fields so they look like this

This should be done for all Routers and switches.

When adding the next device remember to change the Port numbers in this box so that they correspond with our pre-configured ports.

For example

R1 Port 2001

R2 Port 2002

R3 Port 2003

R4 Port 2004

R5 Port 2005

R6 Port 2006

BB1 Port 2011

BB2 Port 2012

BB3 Port 2013

SW1 Port 3001

SW2 Port 3002

SW3 Port 3003

SW4 Port 3004

And That’s it!!!