Using GNU Screen w/ dynamips/dynagen - danshtr way

From Internetworkpro

Jump to: navigation, search
Blank.png This page contains configuration examples or information on dynamips
The examples on this page are intended for use with dynamips, the Cisco router emulator. This information is not intended for use on hardware routers, and is primarily used for troubleshooting, testing, and certification lab study.
Support of Dynamips is found on Hackis_Forum. For other dynamips pages see Category:Dynamips

This is based on loceur's work.

Why should you use "screen" with dynagen? Here is why:

1. Easier to switch from router to router
2. Built in logging of your session, if you choose too
3. History per router
4. Each time you reopen screen (screen -x) you are back to the EXACT point from where you left your routers
5. Now you know one of the most powerful tools in unix/linux
6. No need to waste CPU on another router for terminal server
7. A great way to keep the dynamips server up while away

First read this nice screen tutorial: [1]

In your home directory append/create to the following file : ~/.screenrc . This will set status line parametes.

bind e select 10
hardstatus alwayslastline "%{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%?"


Edit your dynagen.ini file to run screen when connecting to a router:

telnet = screen -t %d  telnet %h %p


Now each time you will use the connect command in dynagen, a new screen "window" will open with the name of the router. The problem is that screen will set the number of the "window" to the next available number. Which means that R2 can be in window "3".

To fix that, create a script file which will later be used to place the screen "windows" to their logical positions. Make sure to put the script to your $PATH and "chmod a+x script_name"

screen -X at CellModeATM number  0
screen -X at R1 number 1
screen -X at R2 number 2
screen -X at R3 number 3
screen -X at R4 number 4
screen -X at R5 number 5
screen -X at R6 number 6
screen -X at R7 number 7
screen -X at R8 number 8
screen -X at R9 number 9
screen -X at DYNG number 10
screen -X at BB1 number 11
screen -X at BB2 number 12
screen -X at BB3 number 13


"screen -X at R2 number 2" will run the command "number 1" at a screen window whos title is "R2". "number 2" command will move the "window" to be placed in slot 2.

Now you are set to start using screen and dynagen.

use the command "screen" to start a screen session

Now run the dynamips server:

dynamips -h 7200


Screen danshtr 1.png
Now create another "window" using ^A C (control A and then C)

Now set the title of the window to DYNG using ^A : (semicolon)

title DYNG


Screen danshtr 2.png

Now start dynagen and start R1 R2 R3 and connect to R1 R2 R3 using the "con R1 R2 R3" command.

Go to the window list and notice in what a mess the windows are. ^A " (double quote)

Screen danshtr 3.png

To fix that choose the DYNG window from the list, and now its time to run the script I have mentioned earlier. I called my script "sc_ie". Type the following from dynagen console:

!sc_ie



NOTE: You might need to run it several times!



Screen danshtr 4.png
At the end this will sort out...

Now to move from a router to router use ^A " or ^A <ROUTER_NUMBER>

To move to the dynagen console ^A E

Enjoy!
-danshtr

Personal tools
Namespaces
Variants
Actions
Navigation
Categories
Toolbox