Sunday 20 February 2011

Slight workflow increase when using Dynamips

I'm still working my way through the IP Expert Volume 3 Workbooks - primarily going through the troubleshooting sessions at the moment since I don't have the largest amount of time available right now and a 2 hour session under a bit of pressure is a good thing to keep me motivated.

Anyway, the topic for discussion here is about how to slightly speed up getting ready to do a lab - probably a lot of people do something similar already, it's just unfortunate that I have really only woken up to the fact that this can help save about 15-20 minutes and reduce errors.

Firstly - this doesn't help much with when you're using real routers - When I finish up with the lab, I get them erased and reloaded so they're all nice an clear of IOS config and VTP related config

Cat1#wr erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
*Mar  1 03:18:23.937: %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
Cat1#del vlan.dat
Delete filename [vlan.dat]?
Delete flash:vlan.dat? [confirm]
Cat1#reload
Proceed with reload? [confirm]
*Mar  1 03:18:31.672: %SYS-5-RELOAD: Reload requested by console. Reload Reason: Reload command.

On my Ubuntu box, I keep all of the configs I use in a directory funnily enough called cisco:

adam@RouterSim:~/cisco$ pwd
/home/adam/cisco

I then have all the related labs living in sub directories - for example the Volume 3 labs are simply unzipped into a directory called ipexpert_vol3

adam@RouterSim:~/cisco$ ls ipexpert_vol3
LAB-10C  LAB-10T  LAB-1C  LAB-1T  LAB-2C  LAB-2T  LAB-3C  LAB-3T  LAB-4C  LAB-4T  LAB-5C  LAB-5T  LAB-6C  LAB-6T  LAB-7C  LAB-7T  LAB-8C  LAB-8T  LAB-9C  LAB-9T  R&S_Volume_3_Diagrams_v11.0.pdf

The dynamips.net config file I use is set up to a generic version what I used previously the main thing I want to highlight is the reference to "currentlab" in the working dir and cnfg lines, the trick I will be using is "softlinks" to point to the specific lab of interest and be able to load up the lab configs without needing a separate .net file per lab when I start dynamips...



start of ipexpert.net
autostart = false
ghostios = true
sparsemem = true
[localhost]
        workingdir = /home/adam/cisco/currentlab/work_ipexpert
        [[7200]]
                image = /opt/ios/unzipped/c7200-adventerprisek9-mz.124-24.T.bin
                npe = npe-400
                ram = 384
                idlepc = 0x6307ad74
                disk0 = 128

        [[2611]]
                image = /opt/ios/unzipped/c2600-js-mz.123-17a.bin
                ram = 64
                idlepc = 0x803266c4
        [[3725]]
                image = /opt/ios/unzipped/c3725-advsecurityk9-mz.124-15.T12.bin
                #/opt/ios/unzipped/c3725-adventerprisek9-mz.124-15.T10.bin
                ram = 128
                #idlepc = 0x6307ad74
                disk0 = 64
                idlepc = 0x60bb28d0

        [[ROUTER R1]]
                model = 7200
                console = 2001
                slot0 = PA-C7200-IO-2FE
                f0/0 = NIO_gen_eth:eth0.101
                f0/1 = NIO_gen_eth:eth0.102
                cnfg = /home/adam/cisco/currentlab/INITIAL/R1.txt

        [[ROUTER R2]]
                model = 7200
                console = 2002
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.201
                f0/1 = NIO_gen_eth:eth0.203
                s2/1 = FR s0/0
                s2/2 = R5 s2/2
                cnfg = /home/adam/cisco/currentlab/INITIAL/R2.txt

        [[ROUTER R4]]
                model = 7200
                console = 2004
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.401
                f0/1 = NIO_gen_eth:eth0.402
                s2/0 = FR s0/1
                cnfg = /home/adam/cisco/currentlab/INITIAL/R4.txt

        [[ROUTER R5]]
                model = 7200
                console = 2005
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.501
                f0/1 = NIO_gen_eth:eth0.502
                s2/1 = FR s0/2
                cnfg = /home/adam/cisco/currentlab/INITIAL/R5.txt

        [[ROUTER R6]]
                model = 7200
                console = 2006
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.601
                f0/1 = NIO_gen_eth:eth0.602
                s2/1 = FR s0/3
                s2/2 = R9 s2/2
                s2/3 = R9 s2/3
                cnfg = /home/adam/cisco/currentlab/INITIAL/R6.txt

        [[ROUTER R7]]
                model = 7200
                console = 2007
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.701
                f0/1 = NIO_gen_eth:eth0.702
                s2/0 = R8 s2/0
                cnfg = /home/adam/cisco/currentlab/INITIAL/R7.txt

        [[ROUTER R8]]
                model = 7200
                console = 2008
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.801
                f0/1 = NIO_gen_eth:eth0.802
                cnfg = /home/adam/cisco/currentlab/INITIAL/R8.txt

        [[ROUTER R9]]
                model = 7200
                console = 2009
                slot0 = PA-C7200-IO-2FE
                slot2 = PA-4T
                f0/0 = NIO_gen_eth:eth0.901
                f0/1 = NIO_gen_eth:eth0.902
                cnfg = /home/adam/cisco/currentlab/INITIAL/R9.txt

        [[ROUTER BB1]]
                model = 2611
                console = 2101
                e0 = NIO_gen_eth:eth0.11
                e1 = NIO_gen_eth:eth1
                cnfg = /home/adam/cisco/currentlab/INITIAL/BB1.txt

        [[ROUTER BB2]]
                model = 2611
                console = 2102
                e0 = NIO_gen_eth:eth0.22
                cnfg = /home/adam/cisco/currentlab/INITIAL/BB2.txt

        [[ROUTER BB3]]
                model = 2611
                console = 2103
                e0 = NIO_gen_eth:eth0.33
                cnfg = /home/adam/cisco/currentlab/INITIAL/BB3.txt

        [[ROUTER FR]]
                model = 3725
                console = 2104
                WIC0/0 = WIC-2T
                WIC0/1 = WIC-2T
                cnfg = /home/adam/cisco/IPExpertFrame.txt
end of ipexpert.net

IPexpertFrame.txt refers to a configuration for the FR Switch rather than use the built in frame relay switch capacity of dynamips:

start of IPExpertFrame.txt
hostname FR
!
interface Serial0/0
 description R2
 no ip address
 encapsulation frame-relay
 clock rate 2000000
 frame-relay lmi-type cisco
 frame-relay intf-type dce
 frame-relay route 104 interface Serial0/1 401
 frame-relay route 105 interface Serial0/2 501
 frame-relay route 106 interface Serial0/3 601
 frame-relay route 204 interface Serial0/1 402
 frame-relay route 205 interface Serial0/2 502
 frame-relay route 206 interface Serial0/3 602
 frame-relay route 214 interface Serial0/1 412
 frame-relay route 215 interface Serial0/2 512
 frame-relay route 216 interface Serial0/3 612
 frame-relay route 224 interface Serial0/1 422
 frame-relay route 225 interface Serial0/2 522
 frame-relay route 226 interface Serial0/3 622
 no shutdown
!
interface Serial0/1
 description R4
 no ip address
 encapsulation frame-relay
 clock rate 2000000
 frame-relay lmi-type cisco
 frame-relay intf-type dce
 frame-relay route 401 interface Serial0/0 104
 frame-relay route 402 interface Serial0/0 204
 frame-relay route 405 interface Serial0/2 504
 frame-relay route 406 interface Serial0/3 604
 frame-relay route 412 interface Serial0/0 214
 frame-relay route 415 interface Serial0/2 514
 frame-relay route 416 interface Serial0/3 614
 frame-relay route 422 interface Serial0/0 224
 frame-relay route 425 interface Serial0/2 524
 frame-relay route 426 interface Serial0/3 624
 no shutdown
!
interface Serial0/2
 description R5
 no ip address
 encapsulation frame-relay
 clock rate 2000000
 frame-relay lmi-type cisco
 frame-relay intf-type dce
 frame-relay route 501 interface Serial0/0 105
 frame-relay route 502 interface Serial0/0 205
 frame-relay route 504 interface Serial0/1 405
 frame-relay route 506 interface Serial0/3 605
 frame-relay route 512 interface Serial0/0 215
 frame-relay route 514 interface Serial0/1 415
 frame-relay route 516 interface Serial0/3 615
 frame-relay route 522 interface Serial0/0 225
 frame-relay route 524 interface Serial0/1 425
 frame-relay route 526 interface Serial0/3 625
 no shutdown
!
interface Serial0/3
 description R6
 no ip address
 encapsulation frame-relay
 clock rate 2000000
 frame-relay lmi-type cisco
 frame-relay intf-type dce
 frame-relay route 601 interface Serial0/0 106
 frame-relay route 602 interface Serial0/0 206
 frame-relay route 604 interface Serial0/1 406
 frame-relay route 605 interface Serial0/2 506
 frame-relay route 612 interface Serial0/0 216
 frame-relay route 614 interface Serial0/1 416
 frame-relay route 615 interface Serial0/2 516
 frame-relay route 622 interface Serial0/0 226
 frame-relay route 624 interface Serial0/1 426
 frame-relay route 625 interface Serial0/2 526
 no shutdown
!
end
end of IPExpertFrame.txt

So the deal with the softlinks is to point "currentlab" to the lab you want to work on for example:


adam@RouterSim:~/cisco$ ln -s ipexpert_vol3/LAB-4T/ currentlab
adam@RouterSim:~/cisco$ ls -l currentlab
lrwxrwxrwx 1 adam adam 21 2011-02-20 18:45 currentlab -> ipexpert_vol3/LAB-4T/

Here are a few house keeping tasks that could be easily scripted away - create a working directory for dynamips files to go into and to rework the standard IPExpert config to match the interfaces in my topology


adam@RouterSim:~/cisco$ mkdir currentlab/work_ipexpert
adam@RouterSim:~/cisco$ cd currentlab/INITIAL/
adam@RouterSim:~/cisco/currentlab/INITIAL$ reworkcfg
adam@RouterSim:~/cisco/currentlab/INITIAL$ cd ../..

To load the config onto the external switches, we just paste the output from

adam@RouterSim:~/cisco$ cat currentlab/INITIAL/Cat1.txt
adam@RouterSim:~/cisco$ cat currentlab/INITIAL/Cat2.txt 
adam@RouterSim:~/cisco$ cat currentlab/INITIAL/Cat3.txt  
adam@RouterSim:~/cisco$ cat currentlab/INITIAL/Cat4.txt

So we just start things up normally and go on our merry lab way

adam@RouterSim:~/cisco$ sudo dynagen ipexpert.net
Reading configuration file...

Network successfully loaded

Dynagen management console for Dynamips and Pemuwrapper 0.11.0
Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa

=> start /all
100-VM 'R4' started
100-VM 'R5' started
100-VM 'R6' started
100-VM 'R7' started
100-VM 'R1' started
100-VM 'R2' started
100-VM 'FR' started
100-VM 'R8' started
100-VM 'R9' started
100-VM 'BB3' started
100-VM 'BB2' started
100-VM 'BB1' started

Once we have finished the with lab and exited dynagen, we tidy up:

That is write erase/del vlan.dat/reload on the switches and
 
adam@RouterSim:~/cisco$ rm currentlab

Now we're ready for the next lab session: