You are not logged in.

Hi All,
I'm working on the CCIE certification, thought I would share with you my scripts for building a virtual LAB. I'm using ArchLinux and the latest CSR-1000V (ISO) as of June 20th. Cisco should allow you to download this ISO for free. You'll be limited to 100kb/sec out of the box, but you can also get a free 60-day eval license that will unlock 50MB/sec.
These scripts assume you have QEMU installed of course, bridge-tools, etc.
Probably want to enable KSM first ![]()
echo 1 >/sys/kernel/mm/ksm/runThis script makes one virtual disk per virtual router. I suppose you could boot one router, let it go through the install, then power it off. Then use that disk as the parent for many others (qemu backing_file). However, the CSR-1000V seems to generate various UUID's for itself during this process and I wasn't sure how this might affect the trial license.
Boot'em up:
# How many vrouters you want
ROUTERS="1 2 3"
# Location of your ISO
ISO="/mnt/nfs/downloads/csr1000v-universalk9.03.15.00.S.155-2.S-std.iso"
# Path virtual hard drive storage
VDISKS="/srv/qemu"
# Build Virtual Disks (might only want to do this once)
for x in $ROUTERS; do
sudo qemu-img create -f raw $VDISKS/r$x.raw 8G
done
for x in $ROUTERS; do
sudo nice qemu-system-x86_64 -name r$x -daemonize -enable-kvm \
-nodefconfig -nodefaults -no-shutdown -rtc base=utc \
-S -cpu host -m 4096 -smp 1,sockets=4,cores=1,threads=1 -balloon virtio \
-drive if=virtio,media=disk,cache=none,format=raw,file=$VDISKS/r$x.raw \
-drive if=ide,index=1,media=cdrom,file=$ISO \
-net nic,vlan=1,macaddr=68:09:68:09:68:5$x,model=virtio \
-net tap,vlan=1,script=no \
-net nic,vlan=2,macaddr=68:09:68:09:69:5$x,model=virtio \
-net tap,vlan=2,script=no \
-serial telnet:127.0.0.1:720$x,server,nowait \
-monitor telnet:127.0.0.1:710$x,server,nowait,nodelay \
-nographic
echo Booting Router $x
doneNote that VM's boot in CPU suspended state. That's because the CSR-1000V ISO installer doesn't correctly auto-detect serial-console mode, so you have to manually select it (but only on first boot, subsequent boots seem to get it right).
So, get xterm's going and in each one, telnet to the virtual serial port: 7201, 7202, 7203, and so on for each router.
Boot them each with this command
echo "cont" | nc 127.0.0.1 7101
echo "cont" | nc 127.0.0.1 7102
and so onNow just tie together the interfaces however you want. For the connectivity in the picture, use the following:
# Build lab ethernet segments
for x in 1 2 3; do
brctl addbr lab$x
ip link set up dev lab$x
done
# Bring up tap devices - allocated by QEMU but not up'd
for x in 0 1 2 3 4 5; do
ip link set up dev tap$x
done
# Virtually plug in our ethernet cables to correct switch ports
brctl addif lab1 tap0
brctl addif lab1 tap2
brctl addif lab2 tap3
brctl addif lab2 tap5
brctl addif lab3 tap1
brctl addif lab3 tap4Sample configurations for each router:
Router 1:
en
conf t
hostname r1
no ip domain-lookup
cdp run
int gi1
ip address 192.168.101.1 255.255.255.0
cdp enable
no shut
int gi2
ip address 192.168.103.1 255.255.255.0
cdp enable
no shut
router eigrp 6809
network 192.168.101.0
network 192.168.103.0
redistribute connected
endRouter 2
en
conf t
hostname r2
no ip domain-lookup
cdp run
int gi1
ip address 192.168.101.2 255.255.255.0
cdp enable
no shut
int gi2
ip address 192.168.102.2 255.255.255.0
cdp enable
no shut
router eigrp 6809
network 192.168.101.0
network 192.168.102.0
redistribute connected
end
wrRouter 3
en
conf t
hostname r3
no ip domain-lookpu
cdp run
int gi1
ip address 192.168.103.3 255.255.255.0
cdp enable
no shut
int gi2
ip address 192.168.102.3 255.255.255.0
cdp enable
no shut
router eigrp 6809
network 192.168.102.0
network 192.168.103.0
redistribute connected
end
wrLast edited by gshearer (2015-06-20 16:47:36)
--
George Shearer
doc at lame dot org
Linux Nerd since the MCC Interim Days
Offline
Very Interesting, but i think it fits better in the wiki then on forum.
Care to create a wiki page ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
WIKI page would be good - but I want to integrate the Nexus for KVM virtual switch with my lab first. If only there were more than 24 hours in a day!
--
George Shearer
doc at lame dot org
Linux Nerd since the MCC Interim Days
Offline