Friday, June 14, 2013

Small tips on bash

Famous tips but I didn't know before.

1. Oh, I forgot to type sudo and got permission error...
Type
$ sudo !!

Here, !! refers to the previous command issued.


2. I don't wanna type that lengthy command or arguments or whatever again...
Type first several letters of the command and hit ^r (Control - r). If the completed command is not what you want, type ^r again and again until you get what you want.

^r searches command history and complete the command line. You can see your command line history with "history" command. Each command line history has an index, and a command can be reissued by typing ! followed by a index number. (e.g. $ !1)

Sunday, June 2, 2013

Updated: Installing wireshark & GNS3 & QEMU on Ubuntu 12.04 x86 64 on VMware Fusion 5

The following procedure installs the latest GNS3 and QEMU as of June 2, 2013.
# The procedure for a physical Ubuntu box should be the same as the following.

Environment
HW: rMBP Mid 2012
OS: OS X 10.8.2
VMware Fusion: 5.0.2
VM OS: Ubuntu 12.04 x86 64

1. Wireshark installation
Installing the wireshark package
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install wireshark
Setting a permission to dumpcap to use wireshark from a non-root user
$ sudo groupadd wireshark
$ sudo usermod -a -G wireshark USERNAME
$ sudo chgrp wireshark /usr/bin/dumpcap
$ sudo chmod 750 /usr/bin/dumpcap
$ sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap

2. QEMU installation
Updated: The following procedure instals Qemu 1.5. If you want to run ASA on GNS3, you need UDP tunnel patched qemu 0.11 or 0.14 instad of the latest Qemu.

# Download UDP tunnel patched qemu 0.11 or 0.14, unpack the tar, and run the installation script after reading README.
# http://sourceforge.net/projects/gns-3/files/Qemu/Linux/

2.1. Enabling vmx on VMware Fusion 5 (only for Fusion 4 and later with a capable physical CPU)

Edit the file when the VM is shut down.
$ cd /Users/USERNAME/Documents/Virtual\ Machines.localized
$ vim MACHINE_NAME.vmwarevm/MACHINE_NAME.vmx

Adding the folloing line to the MACHINE_NAME.vmx file
vhv.enable = "TRUE"

Check the cpuinfo
$ cat /proc/cpuinfo | grep vmx

2.2. Installing dependencies for GNS3 and QEMU
texinfo is for QEMU's man. QEMU requires autoconf and libtool to make
$ sudo apt-get install zlib1g-dev libsdl1.2-dev libpcap-dev texinfo autoconf libtool
$ sudo apt-get install qt4-dev-tools

# If gcc is not installed
# $ sudo apt-get install build-essential

2.3. Installing QEMU 1.5
$ wget http://wiki.qemu-project.org/download/qemu-1.5.0.tar.bz2
$ tar jxvf qemu-1.5.0.tar.bz2
$ cd qemu-1.5.0
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

3. GNS3 0.8.3.1 Installation
$ wget http://downloads.sourceforge.net/project/gns-3/GNS3/0.8.3.1/GNS3-0.8.3.1-src.tar.bz2
$ tar jxvf GNS3-0.8.3.1-src.tar.bz2
$ sudo mv GNS3-0.8.3.1-src /opt/GNS3
$ wget http://downloads.sourceforge.net/project/gns-3/Dynamips/0.2.8-RC3-community/dynamips-0.2.8-RC3-community-x86_64.bin
$ chmod 750 dynamips-0.2.8-RC3-community-x86_64.bin
$ sudo mv dynamips-0.2.8-RC3-community-x86_64.bin /opt/GNS3
$ sudo chown -R root:root /opt/GNS3

4. Setting GNS3
General -> General Settings tab
Untick "Launch the project dialog at startup"
General -> Terminal Settings tab
Use Gnome Terminal
General -> GUI Settings
Tick "Always use manual mode when adding links"
Dynamips -> Dynamips
Set "Executable path to Dynamips:" to "/opt/GNS3/dynamips-0.2.8-RC3-community-x86_64.bin"
Tick "Enable sparse memory support"
Qemu -> Qemu Guest
Use "-no-acpi" option for LinuxMicroCore that is provided by GNS3 official site

5. Notes
- GNS3 from apt-get is too old to run some of the IOS images that should be able to run on it.
- QEMU 1.5 (QEMU1.1 and later) includes patches for UDP tunnel and multicast provided by GNS3 official site
- There is no notable differences between qemu and qemu-kvm from 1.3 (See the release note for QEMU 1.3)
- autoconf and libtool are necessary to compile qemu 1.5
- QEMU's KVM support works only "when running a target architecture that is the same as the host architecture".

6. Reference
Enabling Intel VT on VMware
http://communities.vmware.com/docs/DOC-8970
About QEMU patches
http://brezular.wordpress.com/2012/02/12/installation-solaris-sparc-2-6-sunos-5-6-on-qemu-part-1-qemu-installation/