Emulate ASA in GNS3 on Centos/Redhat/Fedora


After successful installation of GNS3 on Centos/Fedora/Redhat, we'll now compile/patch qemu from the source and then extract initrd and kernel files from ASA(asa802-k8.bin) to use with Qemu.

IMP:::This tutorial is based upon the assumption that you have installed GNS3 under /opt/GNS3, Please check here .

First I'll show you Qemu Patch/Compilation part .
First we'll have to install dependencies
[user@admin ~]$ su

Password: (Type in your root password here)

[root@admin /]# yum install ncurses ncurses-devel zlib zlib-devel SDL SDL-devel libpcap libpcap-devel

Let's download and compile Qemu
[root@admin /]#cd /opt/GNS3/

[root@admin GNS3]#wget http://download.savannah.gnu.org/releases/qemu/qemu-0.11.0.tar.gz

[root@admin GNS3]#tar xvzf qemu-0.11.0.tar.gz

[root@admin GNS3]#cd qemu-0.11.0

[root@admin qemu-0.11.0]#wget http://downloads.sourceforge.net/gns-3/qemu-0.11.0-olive.patch?download

[root@admin qemu-0.11.0]#patch -p1 -i qemu-0.11.0-olive.patch

[root@admin qemu-0.11.0]#./configure --target-list=i386-softmmu

[root@admin qemu-0.11.0]#make

[root@admin qemu-0.11.0]#make install

We are done with Qemu compilation, next is ASA.
[root@admin qemu-0.11.0]#cd ..

[root@admin GNS3]#cd IOS

[root@admin IOS]#mkdir ASA

[root@admin IOS]#chmod o+rw -R ./ASA

[root@admin IOS]#cd ASA

[root@admin ASA]#

now download and move if you need pre-configured files asa802-k8.bin leave a comment below along with your e-mail id I'll send the files ASAP or you can google 4 it to this ASA folder.

::coloured coded text is the output of the command::
[root@admin ASA]#hexdump -C asa802-k8.bin > asa802-k8.hex

[root@admin ASA]#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|

[root@admin ASA]#ls -la asa802-k8.bin
-rwxrwxrwx 1 cyberwiz cyberwiz 14524416 Jun 25 18:48 asa802-k8.bin

[root@admin ASA]#echo "14524416 ; ibase=16 ; last - 1228B0" | bc | tail -n 1
13334352

[root@admin ASA]#tail -c 13334352 asa802-k8.bin > asa802-k8.gz

[root@admin ASA]#gzip -d asa802-k8
gzip: asa802-k8.gz: decompression OK, trailing garbage ignored

[root@admin ASA]#mkdir tmp ; cd tmp

[root@admin tmp]#cpio -i --no-absolute-filenames --make-directories < ../asa802-k8
cpio: Removing leading `/' from member names
cpio: Removing leading `/' from member names
61039 blocks


[root@admin tmp]#cp vmlinuz ../asa802-k8.kernel

[root@admin tmp]#cd asa/scripts/

[root@admin scripts]#gedit first_start.sh

Now copy and paste the following in the gedit:

#!/bin/sh

##
## Author: Jeremy Grossmann (2009)
## Contributor: J. Pedro Flor (28 january 2010)
##

FIRST_START=no
if test ! -e /mnt/disk0/lina_monitor
then
cd /asa/scripts/
echo "d" > /asa/scripts/fdisk.pf.in
echo "o" >> /asa/scripts/fdisk.pf.in
echo "n" >> /asa/scripts/fdisk.pf.in
echo "p" >> /asa/scripts/fdisk.pf.in
echo "1" >> /asa/scripts/fdisk.pf.in
echo "1" >> /asa/scripts/fdisk.pf.in
echo ""  >> /asa/scripts/fdisk.pf.in
echo "t" >> /asa/scripts/fdisk.pf.in
echo "4" >> /asa/scripts/fdisk.pf.in
echo "w" >>/asa/scripts/fdisk.pf.in

echo ""
echo -n "Initializing partition..."
/sbin/fdisk /dev/hda < /asa/scripts/fdisk.pf.in > /dev/null 2> /dev/null
echo "done"

echo ""
echo -n "Formating and mounting partition..."
mkdosfs -F 16 /dev/hda1 > /dev/null 2> /dev/null
mount -t vfat -o umask=0000,noatime,check=s,shortname=mixed /dev/hda1 /mnt/disk0 > /dev/null 2> /dev/null
echo "done"
echo ""

cp /asa/bin/lina /mnt/disk0/lina
cp /asa/bin/lina_monitor /mnt/disk0/lina_monitor
FIRST_START=yes
fi

# load drivers
modprobe e100
modprobe e1000
ifconfig eth0 up
ifconfig eth1 up
ifconfig eth2 up
ifconfig eth3 up
ifconfig eth4 up
ifconfig eth5 up

if test $FIRST_START = yes
then
echo ""
echo "          Cisco ASA with Multiple Security Contexts"
echo "          =============================================="
echo ""
echo "This is your first boot, please wait about 2 minutes for 'disk0' creation"
echo "and then execute the following commands inside the Linux prompt:"
echo ""
echo " # cd /mnt/disk0"
echo " # /mnt/disk0/lina_monitor"
echo ""
echo ""
echo ""
echo "Please note to use the following command under ASA to save your configs:"
echo ""
echo " ciscoasa(config)# boot config disk0:/.private/startup-config"
echo " ciscoasa(config)# copy running-config disk0:/.private/startup-config"
echo ""
echo ""
echo ""
echo "To get webvpn working, execute the following commands:"
echo ""
echo " ciscoasa# mkdir disk0:/var"
echo " ciscoasa# mkdir disk0:/var/log"
echo " ciscoasa# mkdir disk0:/csco_config"
echo " ciscoasa# mkdir disk0:/csco_config/97"
echo " ciscoasa# mkdir disk0:/csco_config/97/webcontent"
echo ""
echo "          ( Powered by Pedro Flor )"
echo "          ( pedro.flor@gmail.com  )"
echo ""
exit
fi

echo ""
echo ""
echo "Starting Cisco ASA with Multiple Security Contexts..."
echo ""

cd /mnt/disk0
/mnt/disk0/lina_monitor



Save and close gedit.

[root@admin scripts]#chmod 755 first_start.sh

[root@admin scripts]#cd ../../etc/init.d/

[root@admin init.d]#gedit rcS

Comment out the lina_monitor line and add /asa/scripts/first_start.sh, it should look like.
#!/bin/sh
#------------------------------------------------------------------
# Copyright (c) 2006, 2007 by Cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------

export MOUNT_OPTS=umask=0000,noatime,check=s,posix,shortname=mixed
/bin/sh -c /etc/init.d/rcS.common

export LD_LIBRARY_PATH=/mnt/disk0/lib:/mnt/disk0/lib

# launch our user space processes
#/asa/bin/lina_monitor

/asa/scripts/first_start.sh

Save and close gedit.

[root@admin init.d]#cd ../../

[root@admin tmp]#find . | cpio -o -H newc | gzip -9 > ../asa802-k8.initrd.gz
61045 blocks

Lets cleanup ASA folder(Optional)
[root@admin tmp]#cd ..

[root@admin ASA]#rm -rf asa802-k8 asa802-k8.hex asa802-k8.bin tmp/*

[root@admin ASA]#rmdir tmp

Qemu Settings.




ASA Settings.


Drag and Start the ASA, then right click, Select Console.

First time you save your config, do as follows:
ciscoasa(config)# boot config disk0:/.private/startup-config
ciscoasa(config)# copy running-config disk0:/.private/startup-config

Before switching ASA off, run one more time the following:
ciscoasa#copy run disk0:/.private/startup-config

Hope this tutorial will help you guys to Setup Qemu and Emulate ASA successfully on GNS3.

Happy Learning :)




Share your views...

25 Respones to "Emulate ASA in GNS3 on Centos/Redhat/Fedora"

Michael G. said...

Wow!! This is the BEST tutorial I've found after searching and testing for DAYS!!
Very very clear (of course, I didn't realize I had to "yum install" a few commands not available ;-0 Windows spoiled me).
Thank you a whole bunch.
Now if I can only find a way to create another loopback or TAP interface so I can connect the ASA to the "cloud" and also install ASDM image.


September 20, 2010 at 8:12 AM
cyberwiz2010 said...

You're Welcome, I have already made a tutorial on loopback interface , You can find it here http://networkingtips-tricks.blogspot.com/2010/09/how-to-install-loopback-interface-in.html

Regards


September 20, 2010 at 11:13 AM
emr7 said...

Hi cyberwiz2010,
I am getting the following error;
gzip: asa802-k8.gz: not in gzip format


September 26, 2010 at 11:57 PM
cyberwiz2010 said...

Please check your email , I have sent you Asa initrd and Kernel download links, just download them and add it to gns3 as shown in screen-shots.


September 27, 2010 at 11:09 AM
Mjerodd said...

Hi. Thanks for the detailed instructions. I seem to make it all the way through with no errors but when I right click the asa and select "Console" nothing happens. I don't get an error or anything. What could I be doing wrong?


September 28, 2010 at 2:36 PM
cyberwiz2010 said...

Please recheck the Asa Preference settings in GNS3. Press enter 2-3 times in Console. If you get # ASA is up just mnt the disk0.


September 28, 2010 at 3:54 PM
Mjerodd said...

That was it. There was a slight discrepancy in the ASA preference settings. Thanks so much for your guidance!


September 29, 2010 at 12:01 PM
Naresh said...

You're welcome :)


September 29, 2010 at 12:32 PM
karthikaravind said...

Do we need separate files for running ASA in GNS3 in single and multiple context modes ? If yes could you please send me the files needed for running ASA in GNS3 in Single context mode
E-Mail ID : karthikaravind (at) gmail.com


October 17, 2010 at 2:04 PM
Ravi DN said...

Hello Naresh,

I am using GNS3 in windows. will you be able to help me out with the Asa initrd and Kernel.

Regards,
Ravi DN.
ravidn22@gmail.com.


January 4, 2011 at 7:35 PM
Naresh said...

Check your gmail inbox for the download link.


January 4, 2011 at 10:33 PM
binaryboy said...

Will these steps to "Emulate ASA in GNS3 on Centos/Redhat/Fedora" work in Ubuntu?


January 9, 2011 at 12:55 PM
Naresh said...

Check your email inbox for ASA Download links. Just add it to GNS3 as shown in the screenshots in "Emulate ASA in GNS3 on Centos/Redhat/Fedora"


January 9, 2011 at 3:30 PM
luckyayo said...

Hi Guys,

I have followed all the steps with no errors, although I am using debian5. But when I try to console into the ASA, its just stays at the telnet prompt and does nothing.

Do you have any ideas?

See below:

Trying 127.0.0.1...
Connected t o127.0.0.1.
Escape character is '^]'.


January 10, 2011 at 4:55 PM
Naresh said...

Plz mail me the screenshots of ASA Setting and Qemu Settings which is under GNS3/Preference here cyberwiz2010@yahoo.com


January 10, 2011 at 8:13 PM
Alejorosado said...

Hi guys ,
thanks so much for the nice tutorial. I got some problems when i start the asa in gns3 , it gets stuck , but before that i got some errors when qemu is mounting the partition :
"Losing too many ticks!
TSC cannot be used as a timesource.
Possible reasons for this are:
You're running with Speedstep,
You don't have DMA enabled for your hard disk (see hdparm),
Incorrect TSC synchronization on an SMP system (see dmesg).
Falling back to a sane timesource now.
"
Probably is because i am not using the right image , could you guys help me please .

Thanks


February 15, 2011 at 1:00 AM
Naresh said...

In case gedit is not working try nano.
nano first_start.sh


February 27, 2011 at 11:59 AM
David Tsulaia said...

Splendid, worked prefect. =))) I get the feeling I am disturbing you too much but I am sure this will be useful for all who are trying to get their CCSP or higher without paying loads of money. Anyway. one final question ( let's hope so) : When I try to create new startup config file (place)
==> boot config disk0:/.private/startup-config
I get this ( or wmthn like it )
==> WARNING boot variable added but unable to find disk0:/.private/startup-config

Basicaly it didn't create new start-up config.
Well running config is active and I am able to work, but for more complex projects it would be nice to be able to save. For people who have similar trouble just do show run command before u close ur work and copy paste the config into text editor save it and after u boot ur ASA next day copy paste it back. and u can continue ur work.

Naresh thanks again for rescuing =)) Awesome work u deserve a medal or at least a hug =D =D


March 2, 2011 at 4:09 PM
David Tsulaia said...

I have =D Press Enter it's awesome button =D the problem with ur ASA is that it does not say connected to dynamips bla bla bla because it shouldn't and it probably confused u.


March 15, 2011 at 10:23 PM
Zahida said...

i have tried all this and still stuck, i also have initrd and kernel dont know where it is wrong. if any possibily to send a copy of these two i will be pleased


October 16, 2011 at 3:08 AM
Zahida said...

will u plz help me out for initrd.gz and kernel files. thanks

zahida


October 16, 2011 at 3:16 AM
Mohamadb said...

Hello Naresh,

I am using GNS3 in Fedora 14. will you be able to send me the Asa initrd and Kernel to my email.

Regards,
Mohamad.
mohamadb@formatech.com.lb


November 30, 2011 at 1:02 PM
SQ said...

Can u assist me with the initrd and kernel for the asa?

squidmin (at) gmail dot com


December 31, 2011 at 2:50 AM
afbar said...

 GREAT JOB and thanks alot for sharing the how to....Just want to mention that those who will be using GNS3-0.8, don't have to specify Qemu options otherwise the ASA kernel will never start...
Next thing is if you got an issue with the execution of the rcS  script kindly use the absolute path and add "."  in front of  "/asa/scripts/first_start.sh"...:)


January 12, 2013 at 10:13 PM
John Mulopa said...

Splendid works. I have been googling for too long and finally you nailed it. Excellent work. Please send me the link for the pre-configured files for asa802-k8.bin. I appreciate your great help


September 5, 2014 at 8:21 PM

Post a Comment

 

Contributors

Our Partners

DISCLAIMER: This site does not store any files on its server. I only index and link to content provided by other sites. All the files are from internet. In case of any query/objection regarding copyright or privacy, please inform me at Contact me and leave your comment here. I will immediately respond to you.