Running your router(s)
Now you have a base olive image. Qemu allows you to use this as a base for other images and only writing the changes to your “slave” images saving on disk space! You can also use less memory for each Qemu instance.
Create a new image off of your base image. Repeat for all your routers you want to emulate:
qemu-img create -b olive-base.img -f qcow2 R1.img |
Start your router and then telnet to it:
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 |
Once logged in, you can type “cli” to launch the JunOS command line interpreter, exit to … exit
and halt to shutdown FreeBSD. Remember to kill your qemu instance(s).
Networking your routers
Ok, one router it’s cool but useless alone. It’s time to make your virtual network! There are many ways to network your olive routers.
Olive to Olive using UNIX sockets
UNIX sockets create a TCP stream between two Qemu instances with one a client and the other a server. Apparently this method creates duplicate packets sometimes.
qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:01:01,model=e1000 \ -net socket,vlan=1,listen=:6000 qemu R2.img -m 96 -nographic -daemonize -serial telnet::2002,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:01:02,model=e1000 \ -net socket,vlan=1,connect=127.0.0.1:6000 |
Olive to Olive using UDP tunnels
UDP tunnels are mainly used to connect to Dynamips/GNS3 emulated routers but can also be used as a more reliable way to connect two Qemu olives together but this can result in much lower latency connections as well.
qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:01:01,model=e1000 \ -net udp,vlan=1,sport=10000,dport=10001,daddr=127.0.0.1 qemu R2.img -m 96 -nographic -daemonize -serial telnet::2002,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:01:02,model=e1000 \ -net udp,vlan=1,sport=10001,dport=10000,daddr=127.0.0.1 |
Olive to real world using TAP interface
One way to connect an interface on your Olive with a real Ethernet NIC is to use a bridge and the Qemu tap option.
Linux:
It is required that you have the generic TUN/TAP driver either built-in to your kernel, or available as a module. To check the availability of this module do the following:
ls -la /dev/net/tun |
If you get no such file or directory, try doing a modprobe tun. It should then appear in the lsmod output.
One way to connect an interface on your Olive with a real Ethernet port is to use a bridge and the net -tap option. This requires you to have the generic TUN/TAP driver either built-in to your kernel, or available as a module. To check the availability of this module do the following:
Let’s say you started the emulator with the following:
qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:00:01,model=e1000 \ -net tap,vlan=1,script=no |
Note the vlan=1 and -net tap options. This basically connects your Olive’s en0 to a virtual tap interface (usually tap0) on your host system. Start up Qemu, and once the emulator is running, proceed to the next step. You’ll need to start up the emulator as root, or change the ownership or permissions on /dev/net/tun.
We’re going to need to now bridge the tap0 interface to another Ethernet interface on the host system. To do this, we’ll utilize the bridge capabilities of Linux. First, get the bridge utilities:
sudo apt-get install bridge-utils |
Let’s assume you want to connect en0 on the Olive to eth1 on the host system.
Do the following as root:
brctl addbr br0 brctl addif br0 eth1 brctl addif br0 tap0 |
This creates a bridge device, br0, and binds the two interfaces to it. Right now everything is still down. Let’s bring it up…
ifconfig eth1 up ifconfig tap0 up ifconfig br0 up |
Now the bridge and member interfaces should be up. Don’t assign any IP addresses to either of the member interfaces. If you want to, you can assign something to br0 if needed. (br0 is analogous an SVI in the Cisco world) To see the status of the bridge, do the following:
brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000cf19ce06c no eth1
tap0 |
Now, assign an IP address to the em0 interface on your Olive, and it should be online. You are also free to tcpdump on the bridge or member interfaces, for debugging. All of this can probably be put into a Qemu interface script, so you can remove the script=no option, and make it a little more automatic.
Your kernel might have ethernet filtering (ebtables, bridge-nf, arptables) enabled, and traffic gets filtered except ARP and STP. The easiest way to disable this is to go to /proc/sys/net/bridge. Check if the bridge-nf-* entries in there are set to 1; in that case, set them to zero and try again. More information on bridges available here.
# cd /proc/sys/net/bridge # ls bridge-nf-call-arptables bridge-nf-call-iptables bridge-nf-call-ip6tables bridge-nf-filter-vlan-tagged # for f in bridge-nf-*; do echo 0 > $f; done
Windows:
Using OpenVPN you can create several tap interfaces with “Add a new TAP-Win32 virtual Ethernet adapter” and rename them with something like ‘Tap1′, ‘Tap2′ and so on
Let’s say we have created 1 Tap interface and renamed it as Tap1. Right click this Tap1 interface on Windows Control Panel – Network Connections and give IP address for example 10.1.1.1/8.
Now you can start Qemu with the -net tap option and ping the interface from your Olive:
qemu -L . -m 96 -hda R1.img -localtime \ -net nic,vlan=1,macaddr=00:aa:00:60:01:01,model=e1000 \ -net tap,vlan=1,ifname=tap0 |
Mac OS X
On Mac OS X, download and install the TunTap package.
qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:00:01,model=e1000 \ -net tap,vlan=1,ifname=tap0,script=no |
We need to give this interface an ip address:
sudo ifconfig tap0 198.18.0.250/24 up |
Olive to real world using PCAP/LACP
In the patch provided in this howto, there is an option to use PCAP or LCAP libraries to bridge directly to a physical interface. You will probable need to run Qemu under Administrator privileges. Please also note that it will stop any other traffic on your interface.
For PCAP:
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 pcap,ifname=eth0 |
For LCAP:
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 lcap,ifname=eth0 |
Please note that you have to configure an IP address your physical interface before being able to communication between your routers. Also I didn’t test PCAP/LCAP on Windows.
Olive to Dynamips or Pemu
The lastest patch also added a udp option to allow networking to a Dynamips or pemu.
qemu R1.img -m 96 -nographic -daemonize -serial telnet::2001,server,nowait \ -localtime -net nic,vlan=1,macaddr=00:aa:00:60:00:01,model=e1000 \ -net udp,vlan=1,sport=10000,dport=10001,daddr=127.0.0.1 |
Then in your dynagen .net file
[[router Cisco1]] fa0/0=NIO_udp:10001:127.0.0.1:10000
Olive to GNS3
Under GNS3, you can create a “Cloud” and configure a NIO UDP (you can add as many NIO UDP as you want). The “Cloud” will be your interface between Olive and GNS3, you can link a firewall or a router per NIO UDP.
Of course, you can do the same with other NIOs like NIO TAP to connect to your olive using a TAP interface.

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?
Hi,
I always encounter this error (ELF Binary Type ’0′ Not Known). Do I missed something?
Thanks
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.
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
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.
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.
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!
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.
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
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?
Where do I put this command
“qemu-img create -f qcow2 olive-base.img 4G”
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!!
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?