Olive reloaded or how to emulate Juniper routers

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

« »

JunOS installation

Now it’s time to install JunOS our FreeBSD image. I used JunOS 8.5R1.14 but your are free to try other versions even if it is usually recommended to have a version less than 8.5. Boot the image and attach a Intel e1000 virtual network card to Qemu:

qemu -m 256 -hda olive-base.img -boot c -localtime \
-net nic,macaddr=00:aa:00:60:01:01,model=e1000 -net user

FreeBSD should start and after login with the root password, you are ready to enter commands:

olive_install_1

Ensure you get an IP address and find out what is your default gateway IP address. Ping it just to be sure it’s working:

dhclient em0
netstat -r
ping 10.0.2.2

olive_install_2

You can use FTP or SCP (or any other way you may think about) to download JunOS in FreeBSD. Here I chose to use SCP. On Mac OS X, don’t forget to activate “Remote login” in System Preferences -> Sharing.

scp user@10.0.2.2:~/Desktop/jinstall-8.5R1.14-domestic-signed.tgz /var/tmp

MacOS_remote_login

The jinstall file after 7.4 version has a binary called checkpic. This binary will fail and the image cannot be installed. Replacing this binary with /usr/bin/true fixes the issue. Also, it is needed to recalculate MD5 and SHA1 checksums before archiving them back. Finally, you can install JunOS with pkg_add.

cd /var/tmp
mkdir jinst-signed
cd jinst-signed
tar zxvf ../jinstall-8.5R1.14-domestic-signed.tgz
 
mkdir jinst
cd jinst
tar zxvf ../jinstall-8.5R1.14-domestic.tgz
 
mkdir pkgtools
cd pkgtools
tar zxvf ../pkgtools.tgz
cd bin
cp /usr/bin/true ./checkpic
cd ..
 
tar zcvf ../pkgtools.tgz *
cd ..
rm -rf pkgtools
 
md5 -q  jinstall-8.5R1.14-domestic-signed.tgz >
jinstall-8.5R1.14-domestic-signed.tgz.md5
openssh sha1 jinstall-8.5R1.14-domestic-signed.tgz >
jinstall-8.5R1.14-domestic-signed.tgz.sha1
 
tar zcfv /var/tmp/jinstall-8.5R1.14-domestic-olive.tgz *
 
pkg_add -f /var/tmp/jinstall-8.5R1.14-domestic-olive.tgz

olive_install_3

Once the jinstall package installed, you can stop FreeBSD by using the halt command and then Qemu by pressing Ctrl-Alt-2, then type: quit. The jinstall above really just installed a bootstrap environment so you need to boot up FreeBSD one more time to finish the installation (depending on your version). If you just restarted your guest above you will notice that you will get no output on your screen. This is because a real Juniper router has no VGA out and redirects everything to the serial port. No worries for us since QEMU will redirect the serial port to either stdio or a telnet port. To do so, launch Qemu with the stdio parameter:

qemu -m 256 -hda olive-base.img -boot c -localtime -nographic -serial stdio

On Mac OS X -nographic is not understand, so just ignore the Qemu window and look at your terminal.

Wait while the bootstrap process completes. The virtual olive will reboot itself automatically and nothing is needed. At the end of this process we will be sitting at a login prompt. Login as root and issue the halt command (CTRL + L if you do not see the prompt) and kill your Qemu proccess.

olive_install_4

On Mac OS X, my terminal was kind of “broken”. To fix this, issue the reset command in your terminal.

Updating JunOS

You can update your version of JunOS from the CLI with the following command:

request system software add [jinstall_package]

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