Olive reloaded or how to emulate Juniper routers

October 29th, 2009 by Jeremy Grossmann Leave a reply »

« »

Installation

Requirements

  • JunOS runs on top of FreeBSD. So you need to download the mini installation ISO, version >= 4.5 because earlier versions don’t support the Intel e1000 interface (em driver). Personally, I used the FreeBSD 4.11 mini-inst ISO but you could use FreeBSD 6 or 7.
  • JunOS itself. If you are smart and patient you will find it. I used jinstall-8.5R1.14-domestic-signed.tgz for my installations.
  • Qemu source code. Again, I used Qemu 0.11.0. You can choose to download it later with wget (I’ll show you how).
  • Download OpenVPN to create TAP interfaces (Windows only, optional).
  • More stuff whether you compile Qemu on Mac OS X, Windows or Linux.

Qemu compilation and patching on Mac OS X

The following procedure has been tested on Mac OS X Snow Leopard.

First you have to install the MacPorts and its dependencies (e.g. latest Apple’s Xcode Developer Tools).

Open a terminal window and install zlib, wget and libpcap via the MacPorts:

sudo port install zlib wget libpcap

Unzip qemu somewhere (e.g. in Documents/JunOS). Then from the qemu directory, patch and compile qemu:

Because FreeBSD hanged a few times when I was installing it inside Qemu, I applied a patch (qemu-0.11.0-macosx) which apparently fixed the problem (this is totally optional, maybe you won’t have any issue if not applied).

wget http://download.savannah.gnu.org/releases/qemu/qemu-0.11.0.tar.gz
tar xvzf qemu-0.11.0.tar.gz
cd qemu-0.11.0
wget http://downloads.sourceforge.net/gns-3/qemu-0.11.0-macosx.patch?download
patch -p1 -i qemu-0.11.0-macosx.patch
wget http://downloads.sourceforge.net/gns-3/qemu-0.11.0-olive.patch?download
patch -p1 -i qemu-0.11.0-olive.patch
./configure --disable-aio --disable-kvm --disable-kqemu --disable-sdl \
--target-list=i386-softmmu
make
sudo make install

Qemu compilation and patching on Windows

If you do not want to compile Qemu on Windows (I can understand that ;) I provide a static version that you can download here.

First some dependencies must be installed, I chose to almost compile everything:

  • Download MinGW and install it (choose custom installation with g++ and make included). The file I downloaded was MinGW-5.1.6.exe
  • Download MSYS and install it, answer yes to post-installation questions and put the correct path to MinGW directory (should be C:\MinGW). The file I downloaded was MSYS-1.0.11.exe.
  • Download and install  Winpcap Developer Pack: extract the contents of \lib and \include folders into \lib and \include folders of your MinGW installation location (should be C:\MinGW\lib and C:\MinGW\include)
  • Start MSYS.
  • Compile and install zlib:
cd
tar -xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/mingw
make
make install
  • Compile and install SDL
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure --prefix=/mingw
make
make install
  • Install coreutils
tar -xvjf coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2

Copy the content of coreutils-5.97-MSYS-1.0.11-snapshot in the MinGW directory (e.g. C:\MinGW). You can also compile and install wget in MSYS or simply use your preferred browser to download Qemu and the patch in the correct directories.

wget http://download.savannah.gnu.org/releases/qemu/qemu-0.11.0.tar.gz
tar -xvzf qemu-0.11.0.tar.gz
cd qemu-0.11.0
wget http://downloads.sourceforge.net/gns-3/qemu-0.11.0-olive.patch?download
patch -p1 -i qemu-0.11.0-olive.patch
./configure --target-list=i386-softmmu
make
make install

Qemu compilation and patching on Linux

Compiling Qemu on Linux (Ubuntu) is quite simple.

First install the dependencies: ncurses, zlib, libpcap-dev and SDL libraries. SDL is optional, you can still use Qemu in a console with the –ncurses option. Then apply the patch and compile Qemu.

sudo apt-get install libncurses5-dev zlib1g-dev libsdl-dev libpcap-dev
wget http://download.savannah.gnu.org/releases/qemu/qemu-0.11.0.tar.gz
tar xvzf qemu-0.11.0.tar.gz
cd qemu-0.11.0
wget http://downloads.sourceforge.net/gns-3/qemu-0.11.0-olive.patch?download
patch -p1 -i qemu-0.11.0-olive.patch
./configure --target-list=i386-softmmu
make
sudo make install

Qemu acceleration

Qemu provides some ways to speed up the emulation, I’ll talk about 2 of them: Kqemu and KVM. Kqemu can be used on both  Windows and Linux. KVM is only for Linux. I do not know if something exists for Mac OS X.

For more details about Kqemu, please have a look at the documentation. For KVM, see the website.

The installation of Kqemu on Windows is relatively easy:

  1. Download Kqemu.
  2. Unzip it.
  3. Locate kqemu.inf and install it (right-click and select Install). In Windows Vista, install Kqemu using the CMD prompt and this command: rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 kqemu.inf
  4. Start Kqemu from the CMD prompt: net start kqemu

Kqemu on Linux (Ubuntu):

  1. Install kqemu with: sudo apt-get install kqemu-source
  2. If you do not want to use sudo each time you start Qemu, give the permissions to /dev/qemu with the following command: sudo chmod o+rw /dev/kqemu

For manual installation or other Linux distributions, please see the documentation.

KVM on Linux:

Qemu requires your kernel version to be >= 2.6.29 to enable the KVM support. You have to ensure this is ok before you compile Qemu.

Don’t forget to add the -kernel-kqemu or -enable-kvm command line options when starting Qemu (I didn’t do it in this tutorial). I would recommend to activate Kqemu only when you have your Olive image ready and working.

133 comments

  1. HakimK says:

    I’ve followed all the instruction but after “qemu -m 256 -hda olive-base.img -boot c -localtime -nographic -serial stdio”, nothing happen. No qemu window appear and I only can see “stderr” and “stdout” files in the Qemu folder.

    stderr notepad shows:
    qemu: could not open serial device ‘mon:stdio’

    stdout notepad shows:
    Unable to open driver: stdio

    I’m trying to install olive in WinXP SP3 with qemu-0.11.0.patched.win32.

    did anyone have the same problem as me?

  2. Philip says:

    Hi,

    I always encounter this error (ELF Binary Type ’0′ Not Known). Do I missed something?

    Thanks

  3. Brad says:

    Everything went smoothly following the directions exactly a written, till I actually got to pkg_add.

    The VM complained about not enough space, saying I needed to change PKG_TMPDIR to a location that had at least 905682568 bytes. I cleaned out files I don’t need any more and made sure PKG_TMPDIR was pointing to /var/tmp. After clening out the files I had 1060060 K bytes free. So that should be enough. But kept getting same error.

  4. juber says:

    O tried to run scp [email protected]:~/Desktop/jinstall-8.5R1.14-domestic-signed.tgz /var/tmp command but request gets timed out.

    I put my PCs hostname instead of user, even i tried with the user i logged in with in my pc but still the request is getting timed out “ssh: connect to host 10.0.2.2 port 22: Operation time out”

    I wasted my 3 days to resolved this don’t know y its not working.

    I had put only “qemu -m 256 -hda olive-base.img -boot c -localtime ” command when booting olive image cause when i put “qemu -m 256 -hda olive-base.img -boot c -localtime \
    -net nic,macaddr=00:aa:00:60:01:01,model=e1000 -net user” the qemu does’n start….

    Please help guys

  5. arvind says:

    hi while trying to upload Junos iam getting following error.

    scp [email protected]:xxxxx\jinstall \var\tmp
    ssh: connect to host 10.0.2.2 port 22: Operation timed out.

    I thought my antivirus firewall might be blocking the udp and tcp packets so disabled that and tried .. then also i was unsuccessful pl help here.

  6. Carlos M says:

    FTR, the pcap check in the patch is wrong.
    Compiler barfs at not caster int return and also,
    the $TMPC should be abefore the $LIBPCAP for the test compile to work.

  7. Max says:

    Does anyone running this on a MAC OS X 10.6 know the replacement option for “-cdrom” in the QEMU command:

    qemu -m 256 -hda olive-base.img -cdrom 4.11-RELEASE-i386-miniinst.iso \ -boot d -localtime

    /Volumes doesn’t work. Using the mount point doesn’t work. I had this working on 10.5, but remember -cdrom didn’t work.

    Any help is appreciated!

    Thanks!

  8. Aamir Maqbool says:

    Hi, I’ve installed the olive by following the above procedure. However I’m facing currently two problems.
    1. I configure the Juniper Router in GNS3 and commit changes bye using commit command. But it does not take effect. until unless I reload all the routers.
    2. I’m unable to find serial interfaces, ATM interfaces & Sonet interfaces.

    Can Anyone provide me the help regarding this.

  9. Cristian Vnd says:

    Resolved JUNOS image upload problem :
    My settings
    - tap-interface with DHCP : ip taken 10.0.2.16
    - Core FTP (mini-sftp-server) to upload your junos image (username=user,password=user)
    then
    sfttp [email protected]:jinstall-8.5R1.14-domestic-signed.tgz /var/tmp
    from your freebsd VM

  10. Ryan says:

    I’m not able to proceed with the following command:

    qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \
    -localtime -net nic,macaddr=00:aa:00:60:01:01,model=e1000 -net user
    telnet localhost 2001

    It produces a stderr.txt file containing:

    qemu: invalid option — `-daemonize`

    If I remove this option, it produces another error:

    qemu: could not open monitor device `stdio`

    Anyone else having this same issue?

  11. neor says:

    Where do I put this command
    “qemu-img create -f qcow2 olive-base.img 4G”

  12. jomih says:

    Hi to all,
    I’ve tried to emulate JUNOS in GNS3 without success.
    When I use the command “qemu -m 256 -hda olive-base.img -boot c -localtime \ -net nic -net tap,ifname=tap0 -net nic,macaddr=00:aa:00:60:01:01,model=e1000 -net user” (in Ubuntu 10.04) and after creating the tap interface with tunctl, I get the following message:
    can’t add tap0 to bridge wlan0: operation not supported
    I’ve tried to do it using the eth0 interface instead of wlan0, but I got the same results.
    can anyone tell me what’s wrong??
    Thanks!!

  13. josem says:

    hi,

    once olive is loaded, I configure an ip address for the en0 interface and do a commit but the check-out fails with this message:

    vci/vpi/allow-any-vci is required

    how is this possible if my interface is en0?

Leave a Reply