When I tried to find the Cisco ASA simulator by Linux keyword, there are few related results came out. Two popular ways are setting up on Windows QEMU and VMWare. People who are using Windows can refer to that.
However, I found one site that is really useful to install ASA image to QEMU on Linux. I followed the steps and make my own ASA environment. Please note that this solution is not user friendly like dynamips or dynagen. Select the two ways above maybe a good choice. So, let’s see how it works in my site.
We need QEMU first
sudo apt-get install qemu
We need asa802-k8.bin
We assume that we are working on $ASA_WORKSPACE. Under the directory, create an hexadecimal dump of image:
hexdump -C asa802-k8.bin > asa802-k8.hex
Search for the ZIP header. We can see that the ZIP file starts at offset 1228b0.
grep “1f 8b 08 00 1d” asa802-k8.hex
001228b0 1f 8b 08 00 1d 3d 73 46 00 03 ec 3a 6d 54 14 57 |…..=sF…:mT.W|
Find the image size.
ls -la asa802-k8.bin
-rw-r–r– 1 hengdu hengdu 14524416 2010-01-28 21:27 asa802-k8.bin
Now we need to find out where in the file we can start extracting the ZIP part.
echo “14524416 ; ibase=16 ; last – 1228B0” | bc | tail -n 1
Extract the zipped part of the ASA image:
tail -c 13334352 asa802-k8.bin > asa802-k8.gz
Decompress it with gzip:
gzip -d asa802-k8
gzip: asa802-k8.gz: decompression OK, trailing garbage ignored
Make a tmp directory and extract the archive with cpio.
sudo cpio -i –no-absolute-filenames –make-directories < ../asa802-k8
cpio: Removing leading `/’ from member names
Copy the Linux kernel to the upper directory:
cp vmlinuz ../asa802-k8.kernel
Make startup script file to ./asa/scripts/first_start.sh. I basically copy all script from the site. However, some part has to be modified in my environment.
if test ! -e /mnt/disk0/lina_monitor
fdisk /dev/hda << EOF
mkdosfs -F 16 /dev/hda1
mount -o umask=0000,noatime,check=s,shortname=mixed /dev/hda1 /mnt/disk0
cp /asa/bin/lina /mnt/disk0/lina
cp /asa/bin/lina_monitor /mnt/disk0/lina_monitor
ifconfig eth0 up
ifconfig eth1 up
ifconfig eth2 up
ifconfig eth3 up
ifconfig eth4 up
ifconfig eth5 up
if test $FIRST_START = yes
echo “This is your first boot, please wait about 1 min and then type the following commands:”
echo “cd /mnt/disk0”
echo “Please note to use the following command under ASA to save your configs:”
echo “copy run disk0:/.private/startup-config”
Chmod for the script
sudo chmod +x ./asa/scripts/first_start.sh
Now you can compress all the file and have the initrd ready to use in Qemu:
sudo find . | cpio -o -H newc | gzip -9 > ../asa802-k8.initrd.gz
At this point, the Linux kernel files are ready for QEMU to use.
Create a virtual hard disk
qemu-img create FLASH 256M
Formatting ‘FLASH’, fmt=raw size=268435456
Then start QEMU
qemu -hda FLASH -kernel asa802-k8.kernel -hdachs 980,16,32 \
-initrd asa802-k8.initrd.gz -m 512 -nographic -append \
“console=ttyS0,9600n8 hda=980,16,32 bigphysarea=16384 auto nousb ide1=noprobe”
After many lines output, you will see # prompt. Then, we start ASA.
Finally, I saw the familiar prompt.
So far, I still have some issues to figure it out, such as interface setup and working with my dynamips router. Hopefully I will figure out later time. Please feel free to join my discussion.
Share on Facebook