Saturday, March 29, 2008

Installing Ubuntu 8.04 & dynamips/dynagen

Today i decided to install Ubuntu again, but this time without using the wubi installer. So i was going to use a partition solely for linux.

It took me around 3 hours and here is the procedure for all of you...

Download latest Ubuntu Desktop LiveCD (8.04 beta was available when i did it). You can run it from the CD before installing it (that's what LiveCDs are all about), if you want to check for any problems (i unfortunately found some regarding my hard disks).

Please keep in mind that this Ubuntu version is still beta, so you shouldn't try it in a production environment. Also, wubi-installer is finally included officially with Ubuntu 8.04, something that could make you life easier, especially if you need more than just a trial run. So you have these 3 options:

1. Run the Ubuntu LiveCD
2. Install Ubuntu in your windows partition (through wubi)
3. Install Ubuntu in a different partition

For my CCIE preparation i used the 2nd option (you can read more details here); this time i'm using the 3rd one.

After you have tried the LiveCD and you have found and solved all booting problems, you can proceed and install Ubuntu in a free partition in your hard disk. I used a 30 GB partition for the root (/) partition and another 2 GB one for the swap partition (i could use a different one for /home too). You don't need to create them before the installation. The installation process can create them, as long as you have some free space (or a windows partition not needed).

Regarding my run/install problems, i had to add the "irqpoll" option to the boot options, because otherwise Ubuntu wouldn't recognize my SATA hard disks (i was getting "ata qc timeout" & "ata revalidation failed" messages). I guess it must be a problem having to do with the JMicron controller of the Abit IP35Pro motherboard (i searched the linux kernel bugs and i found many cases about it). I also removed the "quiet" and "splash" options from the boot parameters line, because i wanted to watch the whole boot process (i don't like things happening behind my back).

You can use the F6 key before installing (or the grub menu options after Ubuntu has been installed) in order to change the boot options. This is before booting/loading Ubuntu. There is a gui (search for "QGRUBEditor" in Synaptic) for changing permanently these options after you have installed/loaded Ubuntu (besides the obvious method of editing the "/boot/grub/menu.lst" file).

After Ubuntu has been installed and loaded correctly, make sure you have connectivity to the internet (i met some problems with my network setup -having ethernet adapters losing their ip addresses- and i had to run "ifdown eth1" & "ifup eth1"). Then run the Update Manager and install all the available updates (i found around 250).

Reboot and everything should be working fine at this time. If not, search for help in the Ubuntu forums, or try the stable 7.10 version. After all, you should already know that Linux is still harder to learn than Windows.

Ok, let's start the Dynamips/Dynagen installation now...

Open Synaptic Package Manager and search for "dynamips". You should find 2 packages : "dynamips 0.2.7-0.2.8RC2-1" & "dynagen 0.10.1-1" (or possibly a newer version of them). Install both of them (i suppose you know how to use Synaptic, or you can use "sudo apt-get").

Now you should have both packages correctly installed. If you run them through a terminal window, you should get the following output:


xxx@ubuntu:~$ dynamips
Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
Copyright (c) 2005-2007 Christophe Fillot.
Build date: Nov 26 2007 06:40:51

Please specify an IOS image filename
Usage: dynamips [options]


xxx@ubuntu:~$ dynagen
Usage: dynagen [options]

xxx@ubuntu:~$ dynagen --version
dynagen 0.10.1.090807


I guess you already have some (already decompressed) IOS around (if it's compressed, try the "unzip -p" command). Otherwise you wouldn't mess with dynamips; would you? For my CCIE preparation i used latest 3640 & 3725 12.4 IOS; you can choose other if you like. Create a directory under /usr/share and put your IOS there. Of course you can choose another directory; i just liked the idea of sharing ;)


xxx@ubuntu:~$ sudo mkdir /usr/share/cisco-ios


You can always copy them from your windows directories (which get automatically mounted once you open them through the file browser/nautilus), like it was in my case (sda1, the 1st partition of my first sata hard disk, is drive letter C: in my windows):


xxx@ubuntu:~$ sudo cp "/media/sda1/Program Files/Dynamips/images/c3640-ik9o3s-mz.124-17a.extracted.bin" /usr/share/cisco-ios/
xxx@ubuntu:~$ sudo cp "/media/sda1/Program Files/Dynamips/images/c3725-adventerprisek9-mz.124-17a.extracted.bin" /usr/share/cisco-ios/


Now change the IOS file permissions and make them readable from everyone (you can always use more strict permissions, if you know how and why):


xxx@ubuntu:~$ sudo chmod 744 /usr/share/cisco-ios/*

xxx@ubuntu:~$ cd /usr/share/cisco-ios/
xxx@ubuntu:/usr/share/cisco-ios$

xxx@ubuntu:/usr/share/cisco-ios$ ls -al
total 144876
drwxr-xr-x 2 root root 4096 2008-03-29 17:52 .
drwxr-xr-x 286 root root 12288 2008-03-29 17:43 ..
-rwxr--r-- 1 root root 65954968 2008-03-29 17:50 c3640-ik9o3s-mz.124-17a.extracted.bin
-rwxr--r-- 1 root root 82221348 2008-03-29 17:52 c3725-adventerprisek9-mz.124-17a.extracted.bin


Create a new directory in your home folder, where you'll be storing your own labs. I like to use a folder on the Desktop, so i can very easily manage it (keep in mind that there are other ways too, if you want to put a folder on the desktop). Create another directory inside it, for your first lab. Also, inside each lab directory you'll need to create a working directory for all the "temporary" files (like nvram contents and ghost-ios files) used for your labs.


xxx@ubuntu:~$ cd Desktop/
xxx@ubuntu:~/Desktop$ mkdir cisco-labs
xxx@ubuntu:~/Desktop$ cd cisco-labs/
xxx@ubuntu:~/Desktop/cisco-labs$
xxx@ubuntu:~/Desktop/cisco-labs$ mkdir lab1
xxx@ubuntu:~/Desktop/cisco-labs$ cd lab1/
xxx@ubuntu:~/Desktop/cisco-labs/lab1$
xxx@ubuntu:~/Desktop/cisco-labs/lab1$ mkdir working


The directory structure should be like the following:


/home/xxx/Desktop/
/home/xxx/Desktop/cisco-labs/
/home/xxx/Desktop/cisco-labs/lab1/
/home/xxx/Desktop/cisco-labs/lab1/working/
/home/xxx/Desktop/cisco-labs/lab2/
/home/xxx/Desktop/cisco-labs/lab2/working/
and so on...


Create the following file ("lab1.net" is your test lab) using your favorite editor. I like vi, you can use gedit.


############
# Lab test
############

autostart = False
[localhost:7200]

# Don't forget to change this for every new lab
workingdir = /home/xxx/Desktop/cisco-labs/lab1/working

[[3640]]
# Specify 3640 IOS image on Linux here:
image = /usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin
#
ram = 128
disk0 = 0
disk1 = 0

# idlepc values are specific to each ios
idlepc = 0x605a5040

mmap = True
ghostios = True
sparsemem = true


[[Router R1]]
model = 3640
console = 2001
slot0 = NM-1FE-TX
F0/0 = SW1 F1/1

[[Router R2]]
model = 3640
console = 2002
slot0 = NM-1FE-TX
F0/0 = SW1 F1/2

[[Router SW1]]
model = 3640
console = 2007
slot1 = NM-16ESW


Now, while in lab1 directory, start dynamips in hypervisor mode and put it in the background (there is still no need to run it as root). Then press enter to see the shell prompt again.


xxx@ubuntu:~/Desktop/cisco-labs/lab1$ dynamips -H 7200 &
[1] 15052
xxx@ubuntu:~/Desktop/cisco-labs/lab1$ Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
Copyright (c) 2005-2007 Christophe Fillot.
Build date: Nov 26 2007 06:40:51

Hypervisor TCP control server started (port 7200).

xxx@ubuntu:~/Desktop/cisco-labs/lab1$


Start dynagen with your first lab as a parameter:


xxx@ubuntu:~/Desktop/cisco-labs/lab1$ dynagen lab1.net

Reading configuration file...

Shutdown in progress...
Shutdown completed.
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0x2142
C3600 instance 'ghost-c3640-ik9o3s-mz.124-17a.extracted.bin-localhost' (id 3):
VM Status : 0
RAM size : 128 Mb
NVRAM size : 128 Kb
Chassis : 3640
IOS image : /usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin

Loading ELF file '/usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin'...
ELF entry point: 0x80008000

C3600 'ghost-c3640-ik9o3s-mz.124-17a.extracted.bin-localhost': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.

C3600 'ghost-c3640-ik9o3s-mz.124-17a.extracted.bin-localhost': stopping simulation.
Network successfully loaded

Dynagen management console for Dynamips
Copyright (c) 2005-2007 Greg Anuzelli

=>


Let's see the routers and the switches now:


=> list
Name Type State Server Console
R1 3640 stopped localhost:7200 2001
R2 3640 stopped localhost:7200 2002
SW1 3640 stopped localhost:7200 2007


Ok, let's start them:


=> start R1
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0x2142
C3600 instance 'R1' (id 1):
VM Status : 0
RAM size : 128 Mb
NVRAM size : 128 Kb
Chassis : 3640
IOS image : /usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin

Loading ELF file '/usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin'...
ELF loading skipped, using a ghost RAM file.
ELF entry point: 0x80008000

C3600 'R1': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
100-VM 'R1' started

=> start R2
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0x2142
C3600 instance 'R2' (id 2):
VM Status : 0
RAM size : 128 Mb
NVRAM size : 128 Kb
Chassis : 3640
IOS image : /usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin

Loading ELF file '/usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin'...
ELF loading skipped, using a ghost RAM file.
ELF entry point: 0x80008000

C3600 'R2': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
100-VM 'R2' started

=> start SW1
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0x2142
C3600 instance 'SW1' (id 0):
VM Status : 0
RAM size : 128 Mb
NVRAM size : 128 Kb
Chassis : 3640
IOS image : /usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin

Loading ELF file '/usr/share/cisco-ios/c3640-ik9o3s-mz.124-17a.extracted.bin'...
ELF loading skipped, using a ghost RAM file.
ELF entry point: 0x80008000

C3600 'SW1': starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
100-VM 'SW1' started


=> list
Name Type State Server Console
R1 3640 running localhost:7200 2001
R2 3640 running localhost:7200 2002
SW1 3640 running localhost:7200 2007
=>


Let's telnet to R2:


=> telnet R2


By default a new xterm window opens, with the following output:


Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connected to Dynamips VM "R2" (ID 2, type c3600) - Console port


% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]: n


Press RETURN to get started!


We repeat the same procedure for every router/switch and we're ready to start our configuration.

In case you need to change the telnet client used by dynagen, you can edit the appropriate line found in file " /etc/dynagen.ini":


# Uncomment below for Linux
telnet = xterm -T %d -e telnet %h %p > /dev/null 2>&1 &


After you have finished with your lab and want to exit dynagen and dynamips, you can do the following:


=> exit
Exiting...
Shutdown in progress...
Shutdown completed.

xxx@ubuntu:~/Desktop/cisco-labs/lab1$ pkill dynamips
xxx@ubuntu:~/Desktop/cisco-labs/lab1$
[1]+ Terminated dynamips -H 7200


This is it! You should now have a fully working dynamips environment under latest Ubuntu 8.04.

14 comments:

  1. Thanks Tassos, I really appreciate your offer! I have already made an Dynamips environment in WinXP and now I'll do the same in Ubuntu.

    Nikos (from Greece as well)

    ReplyDelete
  2. Hi Nikos,

    Dynamips under Windows is working fine as long as you have a good processor and enough memory. Ubuntu is just offering a better experience using less resources.

    Good luck in your preparation (if you're preparing for a certification).

    ReplyDelete
  3. Hello Tassos,

    Great tutorial on Ubuntu & Dynamips/Dynagen.

    I just want to know if it is possible to use SecureCRT in Ubuntu?

    Thanks in advance.

    Mike

    ReplyDelete
  4. You can install Wine (http://www.winehq.org/) and run SecureCRT (and many other windows applications) above it.
    4.x has been tested and works fine.

    ReplyDelete
  5. great tutorial.
    I try to install ubuntu but failed.
    so I install opensuse.
    and i also install dyanamips/dyanagen in opensuse.
    but still not working properly.
    may be I have to try another few days to dyamips get worked.

    ReplyDelete
  6. @batista,

    Have a look at the http://7200emu.hacki.at forums. You'll probably find your solution there.

    ReplyDelete
  7. i have installed dynamips on ubuntu. I have few problems. how do I save my work and I cannot seem to do a cut past on the telnet sessions. Any comments would be appreciated.

    ReplyDelete
  8. If you're referring to the router configurations, you have to use dynagen's "export" command in order to save them.
    Also cut'n'paste depends on your terminal client's settings.

    ReplyDelete
  9. Thank you very much for writing this. I had had a lot of problems with other tutorials but by following this one everything worked like a charm.

    ReplyDelete
  10. Hi, this all works beautifully! The only thing I can't work out how to do, is to make the ethernet port on one of the routers, talk to my local NIC...as this can be done in XP...any ideas? It would be handy because then I can have a router pod running on my laptop, talking to my AMDx64 - it's a great way to help study.
    THanks - marc.mcrae@gmail.com

    ReplyDelete
  11. MarkySharky, you have to use a tap interface and bridge it with the physical one.
    If you google it, you'll probably find a lot of references.

    ReplyDelete
  12. Hi Tassos.. Excellent post... Last time I tried to use Dynamips/Ubuntu, I had a hard time trying to figure out a suitable idlepc value. As a matter of fact, I gave up to find one... Did you have to fine tune anything else other than the idlepc value to make it work? Pls, let me know... Rgrds, Leonardo Hideki

    ReplyDelete
  13. Leonardo, idlepc tuning is needed in order to lower the cpu usage.

    You have to change the idlepc value for each router after major reconfigurations, in order to keep the cpu load as low as possible.

    Generally this is what i do:

    1. Configure all routers/switches without any idlepc values.
    2. Start the switches one by one, finding a idlepc value that keeps the cpu load around 0-1%.
    3. Save the idlepc value to the router portion of the net file ("idlepc save R1").
    4. Start all the switches (you must now have idlepc values for all of them) and begin configuring L2.
    5. As soon as cpu goes above 5%, stop some switches in order to find which switch causes the high cpu load due to the new config (you have to save config very frequently and don't use the config parameter in the net file).
    6. Stop dynagen, go into the net file and comment the idlepc value stored before for this particular switch.
    7. Start dynagen again and try to find the new idlepc value for this switch.
    8. When you find it, save it like in step 3.
    9. Repeat steps 2 though 8 in order to have all switches with full L2 configuration and cpu load around 2-3%.
    10. Then start the routers, repeating the same steps like in the switches.
    11. If later you change a switch in order to add L3 functionality, then you have to repeat the whole "find the idlepc value" process again for this switch.
    12. Finally start the BB routers and repeat the same process.


    I found out that most of the times, idlepc values around 50 are the good ones, despite what dynagen says. Try changing the idlepc value (choosing 1 out of proposed 10) until you get 5%-10% cpu load for all currently running routers.

    I had to repeat the "find the idlepc value" steps around 3-4 times for each router/switch, until i finished the core part of the lab. At that time, cpu was around 7-10%. After that, there was minor increase for the extra configuration, which didn't have any impact on the L2/L3 functionality. If i didn't change the idlepc values, then when the cpu was going above 70%, i was having L2/L3 issues with protocols reseting, interfaces going down, etc.

    When i finished the lab, having all routers with full configuration caused a cpu load around 20-30%, sometimes peaking to 50% (probably due to bgp scanner and wr mem). I guess, that could have been lower, if i was experimenting with idlepc values while at the final config.

    ReplyDelete
  14. Hi - i have latest Unbunto 10.04 LTS version. I installed GNS3-0.7.2-src but when i test dynamips, I get 'dynamips failed to start on port 7200' error message. I have set the dynamips path in GNS correctly. I also allowed port 7200 in iptables on ubuntu. Dynamips version is dynamips-0.2.8-RC2-x86.bin. I changed the permisson of this dynamips file to executable. But after all these effors and spending a week on it, i am still getting same message. Please advise & help.
    Thanks.

    ReplyDelete

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Greece License.