Tutorial: Part 2 of Ultimate Dynamips Dynagen config - focusing on 4 Virtual racks with control scripts.
Welcome to Part 2 of the Ultimate Dynamips Dynagen setup. I hope you enjoyed Part 1. Now that you have the terminal servers configured and automatically starting on boot Its time to setup the Virtual racks. Each virtual rack uses the following topology. The Routers are 2691’s with 12.4 Advanced Enterprise Services. The Switches are 3725’s with a NM-16esw card. The frame cloud is also fully meshed. The layout is per the following diagram. For a Version of this document that includes interface names. Click here ( Sorry about the visio format )
This setup allows for a maximum of four dynamips instances to be running at any given time. Each user has a seperate .net file ( all the same topology ) which allows users to save their configs and resume at a later stage. If a user logs in and starts a different rack than the one previously used the Rackcontrol script rewrites the users .net file and changes the localhost, udp and console port lines to represent the desired rack. If the user has never used the setup before when they first access the rack, Their .net file is automatically created from template.net. So its designed to be Nice and smooth
Firstly we have the required files.
Rackcontrol - Used to start,stop and managed the virtual racks.
template.net - Base .net file used for all users.
You will have to provide copies of ios for obvious reasons. The template.net will need to be changed to represent the location/name of your ios files and possibly router models.
Its also assumed that you have setup your machine according to part 1 of the this article. With the main components being dynamips and dynagen, the directory structure under /data/cisco.
First thing is to copy rackcontrol to /data/cisco and make it executable. Do this with the following code.
cp /path/to/rackcontrol /data/cisco/
chmod +x /data/cisco/rackcontrol
To allow the users to execute the command from anywhere in the filesystem a link is needed. My link is called rack
ln -s /data/cisco/rackcontrol /bin/rack
The template.net also needs to be copied to /data/cisco
cp /path/to/template.net /data/cisco/
Nice and easy so far. Next is a quick check on your file system permissions. This is needed for the users to be able to create their .net files and associated directories. If your dynamips users have a common group, then its easiest to give this group write permissions to /data/cisco. Otherwise you will have to give everyone write access which may be a bad idea and a security risk. In this example I am going to give the group “users” read, write and execute permissions and set the SGID bit which maintains group ownership in the selected directory.
chown .users /data/cisco (change group owner to users, the period indicates a group name is being given)
chmod 2775 /data/cisco ( 2 = sgid, 7=rwx for user owner, 7=rwx for group owner, 5 = rx for everyone else)
I had a requirement to log who was accessing the rack, and how long their session lasted for. This Log file is called usage.log and exists in /data/cisco/logs/. So you have two options now. You can create the log file or disable logging. To create the directories and files execute the following commands.
mkdir /data/cisco/logs
touch /data/cisco/logs/usage.log
chown .users /data/cisco/logs/usage.log
chmod 664 /data/cisco/logs/usage.log
Otherwise to disable logging open the rackcontrol script and put a # symbol in front of lines 43 and 51. As per this example.
line 43:
# RACKLOG start
line 51:
# RACKLOG stop
Save the file and thats it in terms of configuration for now!, In case you haven’t realised, the rackcontrol script is the key to setup. So we are going to start with some troubleshooting to verify if everything works. The most common issues with a setup like this are file permissions locations. So our first part of testing is to verify if everything works as the root user. We are doing this to make sure that the issues are not related to permissions as root has access to everything.
The rack command allows 3 parameters, there are start, stop and list. To start a Virtual rack type
rack start number
To stop a rack type
rack stop number
And to get a listing of the racks and their current usage.
rack list
So as the root user, Try to start a rack. In my example below, we are attempting to start rack 1, As this is roots first time using the rack the first that will happen is the file root.net and the directory root will be created in /data/cisco. The root.net file is created from template.net. Next the script will attempt to rewrite the localhost, udp and console port lines to represent Rack 1. Then dynamips is started for rack 1 and dynagen is then started using the newly created .net file. If all goes well you will end up in the dynagen console interface.
rack start 1
This is my example output from the previous command.
root@host:/> rack start 1
Reconfiguring your topology.
Starting Rack 1 and loading Topology please wait.
Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
Copyright (c) 2005-2007 Christophe Fillot.
Build date: Oct 14 2007 10:41:26
Log file: writing to /data/cisco/root/dynamips.log
ILT: loaded table “mips64j” from cache.
ILT: loaded table “mips64e” from cache.
ILT: loaded table “ppc32j” from cache.
ILT: loaded table “ppc32e” from cache.
Hypervisor TCP control server started (port 7201).
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 0×2142
C2691 instance ‘ghost-C2691-AD.BIN-localhost.ghost’ (id 13):
VM Status : 0
RAM size : 192 Mb
NVRAM size : 128 Kb
IOS image : /data/cisco/ios/C2691-AD.BIN
Loading ELF file ‘/data/cisco/ios/C2691-AD.BIN’…
ELF entry point: 0×80008000
C2691 ‘ghost-C2691-AD.BIN-localhost.ghost’: starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
C2691 ‘ghost-C2691-AD.BIN-localhost.ghost’: stopping simulation.
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0×2142
C3725 instance ‘ghost-C3725-AD.BIN-localhost.ghost’ (id 14):
VM Status : 0
RAM size : 256 Mb
NVRAM size : 128 Kb
IOS image : /data/cisco/ios/C3725-AD.BIN
Loading ELF file ‘/data/cisco/ios/C3725-AD.BIN’…
ELF entry point: 0×80008000
C3725 ‘ghost-C3725-AD.BIN-localhost.ghost’: starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
C3725 ‘ghost-C3725-AD.BIN-localhost.ghost’: stopping simulation.
Network successfully loaded
Dynagen management console for Dynamips and Pemuwrapper 0.11.0
Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa
=>
Obviously there are quite a few issues that could occur at this stage. Please make sure to check the error carefully and try to work out what it relates to, eg file locations. If your still stuck please ask for help using the comments section below.
In the dynagen interface, lets start with the list command, This will verify that the topology file is loaded and that the console port values were rewritten correctly, In my example. I started rack 1, So the console ports all start with 21, for rack 2 expect to see 22, Rack 3 should be 23 and rack 4 would be 24.
=> list
Name Type State Server Console
R1 2691 stopped localhost:7201 2101
R2 2691 stopped localhost:7201 2102
R3 2691 stopped localhost:7201 2103
R4 2691 stopped localhost:7201 2104
R5 2691 stopped localhost:7201 2105
R6 2691 stopped localhost:7201 2106
SW1 3725 stopped localhost:7201 2110
SW2 3725 stopped localhost:7201 2111
SW3 3725 stopped localhost:7201 2112
SW4 3725 stopped localhost:7201 2113
R8 2691 stopped localhost:7201 2116
R7 2691 stopped localhost:7201 2117
R9 2691 stopped localhost:7201 2118
FR0 FRSW always on localhost:7201 n/a
=>
Notice my console ports are all correct!. Great so its time to start some routers. In the dynagen console use the ? to see all available commands, So to start routers R1 and R2 I would use the following command. The device names are CaSe SeNsItIvE. So R1 is different to r1 in linux.
=> start R1 R2
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0x2142
C2691 instance 'R1' (id 4):
VM Status : 0
RAM size : 192 Mb
NVRAM size : 128 Kb
IOS image : /data/cisco/ios/C2691-AD.BIN
Loading ELF file ‘/data/cisco/ios/C2691-AD.BIN’…
ELF loading skipped, using a ghost RAM file.
ELF entry point: 0×80008000
C2691 ‘R1′: starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
100-VM ‘R1′ started
CPU0: carved JIT exec zone of 64 Mb into 2048 pages of 32 Kb.
NVRAM is empty, setting config register to 0×2142
C2691 instance ‘R2′ (id 5):
VM Status : 0
RAM size : 192 Mb
NVRAM size : 128 Kb
IOS image : /data/cisco/ios/C2691-AD.BIN
Loading ELF file ‘/data/cisco/ios/C2691-AD.BIN’…
ELF loading skipped, using a ghost RAM file.
ELF entry point: 0×80008000
C2691 ‘R2′: starting simulation (CPU0 PC=0xffffffffbfc00000), JIT enabled.
100-VM ‘R2′ started
=>
The output indicates that the two routers were succesfully started. So Now i will try to access the routers from the terminal servers that we configured in part 1. Do this by telnetting to Terminal server 1. ( by default with my config files 192.168.1.1) username is rack1 password is cisco. The from the prompt by R1
root@host:/> telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
User Access Verification
Username: rack1
Password:
TermServ1>R1
What We should see now is something similar to the following. If you session appears to be just sitting there. Hit enter a few times.
Trying r1 (192.168.1.10, 2101)... Open
Connected to Dynamips VM "R1" (ID 4, type c2691) - Console port
After hitting Enter We see the usual setup script question.
TermServ1>R1
Trying r1 (192.168.1.10, 2101)... Open
Connected to Dynamips VM "R1" (ID 4, type c2691) - Console port
% Please answer ‘yes’ or ‘no’.
Would you like to enter the initial configuration dialog? [yes/no]:
To get back to the terminal server, press ctrl-shift-6 at the same time, release and then quickly press x .
% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]:
TermServ1>
As you can see I am now back at the terminal server prompt. To connect to R2 I just need to type R2
TermServ1>R2
Trying r2 (192.168.1.10, 2102)... Open
Connected to Dynamips VM "R2" (ID 5, type c2691) - Console port
% Please answer ‘yes’ or ‘no’.
Would you like to enter the initial configuration dialog? [yes/no]:
% Please answer ‘yes’ or ‘no’.
Would you like to enter the initial configuration dialog? [yes/no]:
Again to get back to the terminal server prompt, Ctrl-shift-6, then hit x. To get back to R1 Do NOT type R1 again, As this will attempt to establish another session via the console port which WON’T work. type “show sessions” to see your current sessions.
TermServ1>show sessions
Conn Host Address Byte Idle Conn Name
1 R1 192.168.1.10 0 1 R1
* 2 R2 192.168.1.10 0 0 R2
TermServ1>
The column that is hi-lighted is the key. The connection number is used to resume that session. To resume the session to R1 type 1 and hit enter.
TermServ1>1
[Resuming connection 1 to R1 ... ]
Now We are back in R1 and can continue working. To get back to the terminal server press ctrl-shift-6 then x. Type show sessions again.
TermServ1>show sessions
Conn Host Address Byte Idle Conn Name
* 1 R1 192.168.1.10 0 0 R1
2 R2 192.168.1.10 0 2 R2
TermServ1>
Did anyone notice that the first time I executed the command, R2 had the asterix next to it, Now R1 has the asterix, The asterix identifies your last connection. This is important because we want to resume the connection to R1 all that needs to be done is hit enter. ie no number needed.
TermServ1>
[Resuming connection 1 to R1 ... ]
So if a session of yours has the asterix next it. Just hit enter to resume that session, Otherwise the connection number is needed to resume.
That should be all for now :). I will update this post in the future possibly with better idlepc values and other tweaks I discover as this is still a work in progress. Stay tuned for the video tutorial on using this setup and it should more enjoyable than a wall of text.
Once again thanks for reading and if you have any comments or questions please feel free to leave them.












[...] Part 2 of this tutorial is setting up the 4 virtual racks As usual. If you have any questions of comments please feel free to leave them. [...]
Nice Work man!
[...] Configure your network as per the diagram above ( Viso File link ) edit: the dlci’s are backwards in the diagram. R1 should use dlci 102, R2 should use dlci 201. This lab is compatible with my template.net from my Virtual Racks tutorial. [...]
Now that puts a few diagrams to shame!
Great work!
[...] Part 2 of this tutorial is setting up the 4 virtual racks As usual. If you have any questions of comments please feel free to leave them. (No Ratings Yet) Loading … [...]
Leave your response!
Recent Comments
Blogroll