ASA Emulator with Qemu 2
ccie-sec October 20th, 2008
For quite some time, I’ve been battling with the notion of running an ASA emulator on linux without VMware. Since I couldn’t quite figure it out myself, I had to place the idea on the back burner until I had more time to test. After a few months of dabbling with dynamips, dynagen, and pemu I managed to get it working. Unfortunately I changed too many things on my machine to really know what worked and what didn’t work.
Recently I was asked again by a reader, Azher, if I could do a write up on how to do it. Rather than share my convoluted method and possibly destroying your OS, I found a much easier way to do it just Googling around. The article, How to Set Up A Cisco Lab On Linux (CentOS 5.2), was posted on HowtoForge by Topdog. Just follow his procedure and you should be on your way to running an ASA instance within linux.
FYI, I managed to run his procedure successfully on FC9. Here are my notes:
1) Downloaded RPM files off Topdog’s website
2) Ran ‘rpm’ with the ‘–nodeps’ parameter to avoid the following error:
error: Failed dependencies:
libpcap.so.0.9.4 is needed by dynamips-0.2.8RC2-1.i386[root@xuxu-t61 LAB]# ls *.rpm
dynagen-0.11.0-1.noarch.rpm pemu-0.0.1-20070420.i386.rpm
dynamips-0.2.8RC2-1.i386.rpm[root@xuxu-t61 LAB]# rpm -Uvh –nodeps dynamips-0.2.8RC2-1.i386.rpm
warning: dynamips-0.2.8RC2-1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 990dd808
Preparing…########################################### [100%]
1:dynamips########################################### [100%][root@xuxu-t61 LAB]# rpm -Uvh –nodeps dynagen-0.11.0-1.noarch.rpm
warning: dynagen-0.11.0-1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 990dd808
Preparing…########################################### [100%]
1:dynagen########################################### [100%][root@xuxu-t61 LAB]# rpm -Uvh –nodeps pemu-0.0.1-20070420.i386.rpm
warning: pemu-0.0.1-20070420.i386.rpm: Header V3 DSA signature: NOKEY, key ID 990dd808
Preparing…########################################### [100%]
1:pemu########################################### [100%][root@xuxu-t61 LAB]# service dynamips start [OK]
[root@xuxu-t61 LAB]# service pemu start [OK]
3) Ran dynagen
[root@xuxu-t61 TEST]# dynagen test.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=> list
Name Type State Server Console
R1 3660 stopped localhost:7200 2001
R2 3660 stopped localhost:7200 2002
FW1 525 stopped localhost:10525 4001
SW ETHSW always on localhost:7200 n/a
=> start FW1
100-PEMU ‘FW1′ started
4) Started ‘cpulimit’ to avoid CPU saturation by pemu
[root@xuxu-t61 ~]# ps aux | grep pemu
root 3561 0.2 0.2 21756 5692 pts/0 Sl 13:33 0:00 python /usr/bin/pemuwrapper.py
root 3687 90.2 7.6 177464 156936 pts/0 RN 13:35 0:07 /var/lib/pemu/pemu_public_bin2008-03-04/pemu -net nic,vlan=0,macaddr=00:00:ab:95:e5:00 -net udp,vlan=0,sport=33000,dport=10004,daddr=127.0.0.1 -net nic,vlan=1,macaddr=00:00:ab:95:e5:01 -net udp,vlan=1,sport=33001,dport=10005,daddr=127.0.0.1 -net nic,vlan=2,macaddr=00:00:ab:cd:ef:02 -net nic,vlan=3,macaddr=00:00:ab:cd:ef:03 -net nic,vlan=4,macaddr=00:00:ab:cd:ef:04 -net nic,vlan=5,macaddr=00:00:ab:cd:ef:05 -serial telnet::4001,server,nowait -m 128 FLASH
root 3694 0.0 0.0 4120 696 pts/1 S+ 13:35 0:00 grep pemu[root@xuxu-t61 ~]# cpulimit -e /var/lib/pemu/pemu_public_bin2008-03-04/pemu -l 45
Process 3687 detected
5) Prepped asa724-k8.bin file for usage
[root@xuxu-t61 TEST]# hexdump -C asa724-k8.bin > asa724-k8.hd
[root@xuxu-t61 TEST]# grep “50 4b 03 04 14″ asa724-k8.hd
00017000 50 4b 03 04 14 00 00 00 08 00 32 6e 86 38 03 4c |PK……..2n.8.L|(The hex code ‘50 4b 03 04 14′ denotes PKZip compression)
[root@xuxu-t61 TEST]# ls -la asa724-k8.bin
-rw-r–r– 1 root root 8515584 2008-10-20 17:25 asa724-k8.bin[root@xuxu-t61 TEST]# perl -e ‘$x=8515584-0×17000;print “$x\n”‘
8421376[root@xuxu-t61 TEST]# tail -c 8421376 asa724-k8.bin > asa724.bin.zip
[root@xuxu-t61 TEST]# unzip asa724.bin.zip
Archive: asa724.bin.zip
warning: skipped “../” path component(s) in ../target/f1/pix
inflating: target/f1/pix[root@xuxu-t61 TEST]# cp -v target/f1/pix /var/lib/pemu/images/target/f1/pix
cp: overwrite `/var/lib/pemu/images/target/f1/pix’? yes
`target/f1/pix’ -> `/var/lib/pemu/images/target/f1/pix’
6) Tested ASA emulator
[root@xuxu-t61 ~]# telnet localhost 4001
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.pixfirewall>
If you extracted the files as noted by the article, you’ll notice the PIX name references in the directory structure. I specifically used the asa724-k8.bin file myself and ended up with the same result.
pixfirewall# sh ver
Cisco PIX Security Appliance Software Version 7.2(4)
Compiled on Sun 06-Apr-08 13:39 by builders
System image file is “Unknown, monitor mode tftp booted image”
Config file at boot was “startup-config”pixfirewall up 4 mins 33 secs
Hardware: PIX-525, 128 MB RAM, CPU Pentium II 1 MHz
Flash E28F128J3 @ 0xfff00000, 16MB
BIOS Flash AM29F400B @ 0xfffd8000, 32KB0: Ext: Ethernet0: address is 0000.abee.f300, irq 9
1: Ext: Ethernet1: address is 0000.abee.f301, irq 11
2: Ext: Ethernet2: address is 0000.abee.f302, irq 11
3: Ext: Ethernet3: address is 0000.abee.f303, irq 11
4: Ext: Ethernet4: address is 0000.abcd.ef04, irq 11
The Running Activation Key is not valid, using default settings:Licensed features for this platform:
Maximum Physical Interfaces: 6
Maximum VLANs: 25
Inside Hosts: Unlimited
Failover: Disabled
VPN-DES: Disabled
VPN-3DES-AES: Disabled
Cut-through Proxy: Enabled
Guards: Enabled
URL Filtering: Enabled
Security Contexts: 0
GTP/GPRS: Disabled
VPN Peers: UnlimitedThis platform has a Restricted (R) license.
Serial Number: 123456789
Running Activation Key: 0×00000000 0×00000000 0×00000000 0×00000000 0×00000000
Configuration has not been modified since last system restart.
pixfirewall#
In case you are wondering what my test.net file looks like, here it is:
[root@xuxu-t61 TEST]# cat test.net
autostart = false
[localhost:7200]workingdir = /home/r0ckwell/LAB/TEST
[[3660]]
image = /home/r0ckwell/LAB/TEST/3600img.bin
ram = 96
idlepc = 0×60438e60
disk0 = 0
disk1 = 0
mmap = true
ghostios = true
sparsemem = true[[ROUTER R1]]
autostart = false
model = 3660
console = 2001
F0/0 = SW 1[[ROUTER R2]]
autostart = false
model = 3660
console = 2002
F0/0 = SW 2[[ETHSW SW]]
1 = dot1q 99
2 = dot1q 99
11 = dot1q 99
12 = dot1q 99[pemu localhost]
[[525]]
serial = 123456789
key = 0xffffffff,0xffffffff,0xffffffff,0xffffffffimage = /var/lib/pemu/images/target/f1/pix
[[FW FW1]]
autostart = false
console = 4001
E0 = SW 11
E1 = SW 12



