Showing posts with label Juniper. Show all posts
Showing posts with label Juniper. Show all posts

Sunday, 29 December 2013

Step By Step Guide To Install JunOS on GNS3 [Part 1]

This article explain you how to emulate Juniper JunOS on a PC using Qemu. This is an updated and enhanced
version of excellent howtos from Juniper Clue and Internetwork Pro as well asHimawan Nugroho’s blog. I mainly focused on Qemu, so if you wish to install JunOS on a real PC or using VMware, please have a look at the Juniper Clue article for more information (and of course Google).
So what’s new you would say? First, I chose to use the latest version of Qemu: the 0.11.0 which supports the Intel e1000 network card emulation since version 0.10.0. and includes several fixes for it. I have modified and adapted the old patch for Qemu 0.11.0, it includes the UDP tunnel (connection to dynamips/GNS3), PCAP and LCAP support. Also, the patch allows multicast traffic with the e1000, i82557b and i82559er Qemu emulated network cards.


Moreover, this article show how to emulate JunOS on multiple operating systems: Mac OS X, Windows XP and Linux Ubuntu 9.04 without using an untrustworthy obscure binary downloaded from a forum you can’t even read the language.
 
Disclaimer
Please note that JunOS is not provided and will not be. So please don’t ask. Also, I do not take any responsibility on what happen on your PC, keep in mind this howto requires some patience and that is not for complete beginners. Moreover, this howto doesn’t necessarily present the best and/or easiest way to emulate JunOS. This is the cleanest and less intrusive for me but please feel free to give me constructive comments and tell what worked or didn’t worked for you.


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 ,
zlib, SDL, MSYS coreutils into your MSYS home directory (e.g. c:\Msys\public\username). I downloaded zlib-1.2.3.tar.gz, SDL-1.2.14.tar.gz and coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2. MSYS coreutils is necessary because Qemu signrom.sh uses tools such as dd, od, expr, cp and printf which are included in coreutils.
· 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 thewebsite.
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.

Step By Step Guide To Install JUNOS on GNS3 [Part 2]

FreeBSD installation
Now that we have qemu installed, we can create the image for installing FreeBSD. Run this command to create it and allocate 4 GB:

qemu-img create -f qcow2 olive-base.img 4G
Launch Qemu to install FreeBSD on the image:


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


Qemu window will pop up (remember, by default press CTRL + ALT to release the cursor in Qemu):

 
Skip Kernel configuration:

Once Qemu has booted the FreeBSD installation image, you can select standard installation:

When you see the FDISK Partition Editor, press A to allocate the entire disk for FreeBSD and then Q to confirm:
Select “install a standard MBR” and when you see the FreeBSD Disklabel editor, press C to create the following partitions:

ad0s1a / 1024M
ad0s1b swap 1024M
ad0s1e /config 12M
ad0s1f /var rest



Choose “User” distribution type and answer no for the question “Would you like to install the FreeBSD ports collection?”. Exit the menu and install from a FreeBSD CD/DVD: 
Wait until all the files are installed in your image:
Once the files are copied, the installer program will ask you many user confirmation questions (Ethernet/SLIP config, gateway, inetd, FTP, NFS, security, console, linux compatibility, set time, etc). Just answer no for each of them. You will also be asked to enter a root password, just do and remember it. Now you should see the starting menu of the FreeBSD installer, exit by choosing X Exit Install. While FreeBSD CD is rebooting, quit Qemu by by pressing Ctrl-Alt-2, then type: quit.

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:


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

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

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

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.



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

Friday, 22 February 2013

Juniper JNCIA-Junos - Class of Service

For this last chapter, you are going to mark some traffic.

Exercise – Marking packets

Your goal is to create a filter that you will apply on JUNOS1′s em4 interface (input). This filter will mark all packets from 10.3.3.0/24 with expedited-forwarding (EF) DSCP.

Solution

firewall {
   family inet {
        filter apply-cos {
            term from-JUNOS3 {
                from {
                    source-address {
                        10.3.3.0/24;
                    }
                }
                then {
                    forwarding-class expedited-forwarding;
                    accept;
                }
            }
            term default {
                then accept;
            }
        }
    }
em4 {
     unit 0 {
         family inet {
             filter {
                 input apply-cos;
             }
             address 172.30.25.9/30;
         }
     }
 }
This is the end of our hands-on exercises, you should now be ready to seat for the
JNCIA-Junos certification. Don’t forget you can obtain 50% off the exam cost by passing the pre-assessment exam on Juniper’s website.

Juniper JNCIA-Junos - Routing Policy and Firewall Filters

We assume you have read chapter 2 of Juniper’s second PDF so that you can practice routing policy and firewall filters. First we are going to start with a simple route redistribution followed by a firewall filter to restrict telnet access.

Exercise 1 – Default route redistribution into OSPF

Create a policy to redistribute the existing default route (0.0.0.0/0) on JunOS1 into OSPF so that other routers can use it.

Solution

[edit]
root@JUNOS1# edit policy-options
[edit policy-options]
root@JUNOS1# set policy-statement default-static term accept-default-static from protocol static
[edit policy-options]
root@JUNOS1# set policy-statement default-static term accept-default-static from route-filter 0.0.0.0/0 exact
[edit policy-options]
root@JUNOS1# set policy-statement default-static term accept-default-static then accept
[edit policy-options]
root@JUNOS1# show
policy-statement default-static {
term accept-default-static {
from {
protocol static;
route-filter 0.0.0.0/0 exact;
}
then accept;
}
}
[edit policy-options]
root@JUNOS1# top edit protocols ospf
[edit protocols ospf]
root@JUNOS1# set export default-static
[edit]
root@JUNOS1# commit
JUNOS1 advertises the default route in OSPF, check that JUNOS3 can actually see it.
root@JUNOS3# run show route protocol ospf
inet.0: 15 destinations, 15 routes (15 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
0.0.0.0/0          *[OSPF/150] 00:00:05, metric 0, tag 0
> to 172.30.25.9 via em4.0

Exercise 2 – Firewall filtering

To complete this exercise, we have to activate telnet service on JUNOS1.
[edit]
root@JUNOS1# set system services telnet
[edit]
root@JUNOS1# set system login user junuser class super-user authentication plain-text-password
[edit]
root@JUNOS1# commit
commit complete
Test the service from JUNOS3 using the loopback0 as the source interface.
[edit]
root@JUNOS3# run telnet 10.1.1.1 interface lo0
Trying 10.1.1.1...
Connected to 10.1.1.1.
Escape character is '^]'.
JUNOS1 (ttyp0)
login: junuser
Password:
--- JUNOS 10.1R1.8 built 2010-02-12 17:15:05 UTC

junuser@JUNOS1> exit
Connection closed by foreign host.
Now add a firewall filter to allow telnet access to JUNOS3 loopback0 interface (10.3.3.3) only. You have to define the firewall filter, a prefix list and apply the filter on JUNOS1′s loopback0.

Solution

[edit]
root@JUNOS1# edit firewall filter limit-telnet-access
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-accept from source-prefix-list trusted
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-accept from protocol tcp
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-accept from destination-port telnet
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-accept then accept
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-reject from protocol tcp
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-reject from destination-port telnet
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-reject then discard
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term telnet-reject then log
[edit firewall filter limit-telnet-access]
root@JUNOS1# set term else-accept then accept
[edit firewall filter limit-telnet-access]
root@JUNOS1# show
term telnet-accept {
from {
source-prefix-list {
trusted; ## 'trusted' is not defined
}
protocol tcp;
destination-port telnet;
}
then accept;
}
term telnet-reject {
from {
protocol tcp;
destination-port telnet;
}
then {
discard;
}
}
term else-accept {
then accept;
}
[edit firewall filter limit-telnet-access]
root@JUNOS1# top edit policy-options
[edit policy-options]
root@JUNOS1# set prefix-list trusted 10.3.3.3
[edit policy-options]
root@JUNOS1# top set interfaces lo0 unit 0 family inet filter input limit-telnet-access
Let check we can only connect only from JUNOS3′s loopback0 interface. Also have a look at the firewall log on JUNOS1.
root@JUNOS2# run telnet 10.1.1.1 interface lo0
Trying 10.1.1.1...
^C
[edit]
root@JUNOS3# run telnet 10.1.1.1 interface lo0
Trying 10.1.1.1...
Connected to 10.1.1.1.
Escape character is '^]'.
JUNOS1 (ttyp0)
login:
root@JUNOS1# run show firewall log
Log :
Time      Filter    Action Interface     Protocol        Src Addr                         Dest Addr
01:42:37  limit-telnet-access D em1.0    TCP             10.2.2.2                         10.1.1.1
01:42:33  limit-telnet-access D em1.0    TCP             10.2.2.2                         10.1.1.1
01:42:29  limit-telnet-access D em1.0    TCP             10.2.2.2                         10.1.1.1
01:42:25  limit-telnet-access D em1.0    TCP             10.2.2.2                         10.1.1.1

Juniper JNCIA-Junos - Routing Fundamentals

Starting with Juniper’s second PDF, we can make a new practice lab for the next 3 chapters. This lab is a bit more advanced than the previous one in order to test the OSPF routing protocol. You will need 3 Juniper routers, here are the connections:
  • JUNOS1, interface em0 <-> JUNOS2, interface em0
  • JUNOS1, interface em1 <-> JUNOS2, interface em1
  • JUNOS1, interface em4 <-> JUNOS3, interface em4
  • JUNOS2, interface em3 <-> JUNOS3, interface em3
Make sure the routers have a factory default configuration (use the load factory-default command if you need to). Then set the host-name, root password and IP addresses for each router, to save time you can copy and paste the following commands (don’t forget to commit):

JUNOS1

set system host-name JUNOS1
set interfaces em0 unit 0 family inet address 172.30.25.2/30
set interfaces em1 unit 0 family inet address 172.30.25.6/30
set interfaces em3 unit 0 family inet address 192.168.1.1/24
set interfaces em4 unit 0 family inet address 172.30.25.9/30
set interfaces lo0 unit 0 family inet address 10.1.1.1/24
set system root-authentication plain-text-password

JUNOS2

set system host-name JUNOS2
set interfaces em0 unit 0 family inet address 172.30.25.1/30
set interfaces em1 unit 0 family inet address 172.30.25.5/30
set interfaces em3 unit 0 family inet address 172.30.25.13/30
set interfaces lo0 unit 0 family inet address 10.2.2.2/24
set system root-authentication plain-text-password

JUNOS3

set system host-name JUNOS3
set interfaces lo0 unit 0 family inet address 10.3.3.3/24
set interfaces em3 unit 0 family inet address 172.30.25.14/30
set interfaces em4 unit 0 family inet address 172.30.25.10/30
set system root-authentication plain-text-password
If everything went fine, the topology for your new lab should be like in the following image. Please read chapter one of Juniper’s second PDF before continuing.

Exercise 1 – Static routing

On JUNOS1, configure a default static route (0.0.0.0/0) to next-hop 172.30.25.1.

Solution

Add a second default static route with a preference of 7 to next-hop 172.30.25.5 that should be used as a backup (floating static route) and commit.

Solution

Let’s check that everything is working as expected:
root@JUNOS1# run show route
inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[Static/5] 00:01:54
> to 172.30.25.1 via em0.0
[Static/7] 00:00:13
> to 172.30.25.5 via em1.0
...
[edit]
root@JUNOS1# run ping 10.2.2.2
PING 10.2.2.2 (10.2.2.2): 56 data bytes
64 bytes from 10.2.2.2: icmp_seq=0 ttl=64 time=1.650 ms
64 bytes from 10.2.2.2: icmp_seq=1 ttl=64 time=1.272 ms
root@JUNOS2# run monitor traffic interface em0
...
19:33:03.526742 172.30.25.2 > 10.2.2.2: ICMP echo request, id 16648, seq 0, length 64
[edit]
root@JUNOS1# deactivate interfaces em0
[edit]
root@JUNOS1# commit
commit complete
[edit]
root@JUNOS1# run ping 10.2.2.2
PING 10.2.2.2 (10.2.2.2): 56 data bytes
64 bytes from 10.2.2.2: icmp_seq=0 ttl=64 time=3.247 ms
64 bytes from 10.2.2.2: icmp_seq=1 ttl=64 time=0.658 ms
[edit]
root@JUNOS2# run monitor traffic interface em1
...
19:35:30.376370 172.30.25.6 > 10.2.2.2: ICMP echo request, id 14090, seq 7, length 64

Exercise 2 – OSPF routing

Configure OSPF routing on all interfaces connecting routers and their loopbacks but no adjacency should be formed on interfaces connecting to the 172.30.25.0/30 subnet (172.30.25.1 and 172.30.25.2).

Solution

JUNOS1

set protocols ospf area 0.0.0.0 interface em0.0 passive
set protocols ospf area 0.0.0.0 interface em1.0
set protocols ospf area 0.0.0.0 interface lo0.0
set protocols ospf area 0.0.0.0 interface em3.0
set protocols ospf area 0.0.0.0 interface em4.0

JUNOS2

set protocols ospf area 0.0.0.0 interface em0.0 passive
set protocols ospf area 0.0.0.0 interface em1.0
set protocols ospf area 0.0.0.0 interface lo0.0
set protocols ospf area 0.0.0.0 interface em3.0

JUNOS3

set protocols ospf area 0.0.0.0 interface em3.0
set protocols ospf area 0.0.0.0 interface em4.0
set protocols ospf area 0.0.0.0 interface lo0.0
Let’s check that everything is working as expected:
[edit]
root@JUNOS1# run show ospf neighbor
Address          Interface              State     ID               Pri  Dead
172.30.25.5      em1.0                  Full      10.2.2.2         128    34
172.30.25.10     em4.0                  Full      10.3.3.3         128    32
[edit]
root@JUNOS2# run show ospf neighbor
Address          Interface              State     ID               Pri  Dead
172.30.25.6      em1.0                  Full      10.1.1.1         128    36
172.30.25.14     em3.0                  Full      10.3.3.3         128    38
[edit]
root@JUNOS3# run show ospf neighbor
Address          Interface              State     ID               Pri  Dead
172.30.25.13     em3.0                  Full      10.2.2.2         128    36
172.30.25.9      em4.0                  Full      10.1.1.1         128    35
root@JUNOS3# run show route protocol ospf
...
10.1.1.1/32        *[OSPF/10] 00:04:11, metric 1
...
10.2.2.2/32        *[OSPF/10] 00:04:11, metric 1
...
192.168.1.0/24     *[OSPF/10] 00:00:02, metric 2
> to 172.30.25.9 via em4.0
root@JUNOS3# run traceroute 192.168.1.1
traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 40 byte packets
1  192.168.1.1 (192.168.1.1)  1.611 ms  0.588 ms  1.362 ms
[edit]
root@JUNOS3# deactivate interfaces em4
[edit]
root@JUNOS3# commit
commit complete
[edit]
root@JUNOS3# run traceroute 192.168.1.1

traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 40 byte packets
1  172.30.25.13 (172.30.25.13)  2.316 ms  1.479 ms  0.882 ms
2  192.168.1.1 (192.168.1.1)  1.283 ms  1.300 ms  1.129 ms
Finally, don’t forget to reactivate interface em4 and commit:
[edit]
root@JUNOS3# activate interfaces em4

[edit]
root@JUNOS3# commit
commit complete

Juniper JNCIA-Junos - Operational Monitoring and Maintenance

For the last chapter of Juniper’s first PDF, we are going to have a closer look how to get more information about JunOS and also practice the password recovery procedure that will sooner and later be useful for you.

Exercise 1 – boot messages

Do you remember the booting process in chapter 1? Well you have a command to see the messages again (hint: use the show system command).

Solution

root@JUNOS1# run show system boot-messages
Copyright (c) 1996-2010, Juniper Networks, Inc.
...
ad1: 1024MB <QEMU HARDDISK 0.11.0> at ata0-slave WDMA2
Trying to mount root from ufs:/dev/ad0s1a
vn_read_compressed_block: invalid block index 550

Exercise 2 – JunOS packages

Still about the booting process, we have seen that JunOS packages are loaded on virtual memory disks (you can still see that using the show system storage command). Find the command which list all these packages including their versions.

Solution

root@JUNOS1> show version
Hostname: JUNOS1
Model: olive
JUNOS Base OS boot [10.1R1.8]
JUNOS Base OS Software Suite [10.1R1.8]
JUNOS AppId Services [10.1R1.8]
JUNOS IDP Services [10.1R1.8]
JUNOS Routing Software Suite [10.1R1.8]

Exercise 3 – network interfaces

Now show all interfaces configured on JUNOS1 (equivalent to show ip interface brief on Cisco IOS) and then use a command to show a maximum of details for interface em0.

Solution

root@JUNOS1> show interfaces terse
Interface               Admin Link Proto    Local                 Remote
em0                     up    up
em0.0                   up    up   inet     192.168.1.1/24
192.168.1.3/24
...
root@JUNOS1> show interfaces em0 extensive
Physical interface: em0, Enabled, Physical link is Up
Interface index: 8, SNMP ifIndex: 17, Generation: 134
Type: Ethernet, Link-level type: Ethernet, MTU: 1514, Clocking:
...

Exercise 4 – monitor

Let’s play a bit more with the monitor command. On JUNOS2, monitor all interface traffic (statistics) in real time. From JUNOS1 ping JUNOS2 (192.168.1.2) and check the counters incrementing.

Solution

root@JUNOS2> monitor interface traffic
Interface    Link  Input packets        (pps)     Output packets        (pps)
...
em0           Up           1476                            1302
...

Exercise 5 – password recovery

Now assume you have forgotten the root password for JUNOS2 or maybe you really have, don’t panic, you are going to do a password recovery. First reboot you system and be ready to hit space to get to the kernel command prompt. Then follow the procedure as explained in the documentation.
root@JUNOS2> request system reboot
Reboot the system ? [yes,no] (no) yes
...

Solution

Hit [Enter] to boot immediately, or space bar for command prompt.
<space>
Type '?' for a list of commands, 'help' for more detailed help.
OK boot –s
...
Enter full pathname of shell or 'recovery' for root password recovery or RETURN for /bin/sh: recovery
...
NOTE: Once in the CLI, you will need to enter configuration mode using
NOTE: the 'configure' command to make any required changes. For example,
NOTE: to reset the root password, type:
NOTE:    configure
NOTE:    set system root-authentication plain-text-password
NOTE:    (enter the new password when asked)
NOTE:    commit
NOTE:    exit
NOTE:    exit
NOTE: When you exit the CLI, you will be asked if you want to reboot
NOTE: the system
Starting CLI ...
root> configure
Entering configuration mode
[edit]
root# set system root-authentication plain-text-password
New password:
Retype new password:
[edit]
root# commit
error: could not open database: /var/run/db/juniper.data: No such file or directory
error: Database open failed for file '/var/run/db/juniper.data': No such file or directory
commit complete
[edit]
root@JUNOS2# exit
Exiting configuration mode
root@JUNOS2> exit
Reboot the system? [y/n] y
Well done, you completed all exercises for Juniper’s first PDF, now it is time to go into more serious stuff with the second PDF and Routing Fundamentals

Juniper JNCIA-Junos - Secondary System Configuration

Before diving deeper into JunOS configuration you should have read chapter 4 of Juniper’s first PDF. Let’s continue with the same lab as before.

Exercise 1 – Syslog

On JUNOS2, set up a syslog file to record any config changes (hint: system syslog). Commit and quit.

Solution

[edit]
root@JUNOS2# set system syslog file config-changes change-log info
[edit]
root@JUNOS2# commit and-quit
commit complete
Exiting configuration mode
Now go back to configuration mode and change junuser to give operator permissions instead of super-user. Again, commit and-quit. Using the show command, display the log related to your previous commit.

Solution

[edit]
root@JUNOS2# set system login user junuser class operator
[edit]
root@JUNOS2# commit and-quit
commit complete
Exiting configuration mode
root@JUNOS2> show log config-changes
Dec 16 05:06:24  JUNOS2 mgd[1392]: UI_CFG_AUDIT_SET: User 'root' set:
[system login user junuser class] "super-user -> "operator"
Use the help syslog command to learn more about the message code (UI_CFG_AUDIT_SET).

Solution

root@JUNOS2> help syslog UI_CFG_AUDIT_SET
Name:          UI_CFG_AUDIT_SET
Message:       User '<username>' <action>: <pathname> <delimiter><data> ->
"<value>"
Help:          Value has been set for configuration object
Description:   The indicated user set a value for a configuration object, as
indicated.
Type:          Event: This message reports an event, not an error
Severity:      info
From JUNOS1, telnet to JUNOS2 (192.168.1.2), log in and start monitoring the change-log file in real time.

Solution

root@JUNOS1> telnet 192.168.1.2
Trying 192.168.1.2...
Connected to 192.168.1.2.
Escape character is '^]'.
JUNOS2 (ttyp0)
login: junuser
Password:
--- JUNOS 10.1R1.8 built 2010-02-12 17:15:05 UTC
junuser@JUNOS2> monitor start config-changes
Using the console (logged with root) on JUNOS2, delete em1 configuration and cancel your current candidate configuration using the rollback command. The operator connected via telnet should have been informed of what just happened. Stop all monitoring and exit.

Solution

[edit]
root@JUNOS2# delete interfaces em1
[edit]
root@JUNOS2# rollback 0
load complete
junuser@JUNOS2>
*** config-changes ***
Dec 16 05:16:53  JUNOS2 mgd[1392]: UI_CFG_AUDIT_OTHER: User 'root' delete: [interfaces em1]
Dec 16 05:17:12  JUNOS2 mgd[1392]: UI_CFG_AUDIT_OTHER: User 'root' rollback: /config/juniper.conf
...
junuser@JUNOS2> monitor list
monitor start "config-changes" (Last changed Dec 16 05:17:13)
junuser@JUNOS2> monitor stop
junuser@JUNOS2> exit

Exercise 2 – FTP and automated configuration backup

On JUNOS2, activate FTP and commit (hint: use set system services).

Solution

[edit]
root@JUNOS2# set system services ftp
[edit]
root@JUNOS2# commit
commit complete
Back to JUNOS1, configure it to backup any new configuration that becomes active on JUNOS2 (192.168.1.2) using FTP to ftp://junuser@192.168.1.2 (hint: configuration is done in system archival configuration level). Commit once to apply your candidate configuration, delete interface em3 and commit again. After a few seconds your new configuration should be backed up on JUNOS2 (use the file list /var/home/junuser command to check).

Solution

[edit]
root@JUNOS1# edit system archival configuration
[edit system archival configuration]
root@JUNOS1# set transfer-on-commit
root@JUNOS1# set archive-sites ftp://junuser@192.168.1.2 password mypassword
[edit system archival configuration]
root@JUNOS1# commit
commit complete
[edit system archival configuration]
root@JUNOS1# top delete interfaces em3
[edit system archival configuration]
root@JUNOS1# commit
commit complete
[edit]
root@JUNOS1# run show log messages | match juniper.conf
Dec 16 07:06:20  JUNOS1 logger: transfer-file: Transferred
/var/transfer/config/JUNOS1_juniper.conf.gz_20111216_070529
root@JUNOS2> file list /var/home/junuser
/var/home/junuser:
.ssh/
JUNOS1_juniper.conf.gz_20111216_070459

Wednesday, 20 February 2013

Juniper JNCIA-Junos - User Interface Options & Initial Configuration


This page is to practice what you learned in Juniper’s PDF (part 1), chapter 2 and 3.  So now it is time to get active and log in as root without any password.
First thing you should notice is that Amnesiac is the default host-name. This indicates that our JunOS is running with the factory-default configuration (you can use the load factory-default command in configuration mode to have a JunOS in this state).
You are logged in as root, you should see the UNIX shell prompt root@% where you can type UNIX commands like ls or ps but this is beyond our scope. What we want is the operational mode prompt root> that is started with the cli command.
Amnesiac (ttyd0)
login: root
--- JUNOS 10.1R1.8 built 2010-02-12 17:15:05 UTC
root@% cli
root>
Type show configuration to display the current factory-default configuration.
root> show configuration
## Last commit: 2011-02-17 00:34:21 UTC by root
version 10.1R1.8;
system {
    syslog {
        user * {
            any emergency;
        }
        file messages {
            any notice;
            authorization info;
        }
        file interactive-commands {
            interactive-commands any;
        }
    }
    ## Warning: missing mandatory statement(s): 'root-authentication'
}
Note the missing mandatory statement warning, this means you will not be able to commit your changes until you set up a password for root.

Exercise 1 – root password

Go to configuration mode using the configure command and try to commit the current candidate configuration, then set a password for root and commit again.

Solution

Now your JunOS route is ready for new commits! Let’s see if you can apply the same configuration on your second router without looking at the solution above. Remember, you must first login, then go to operational mode and then to configuration mode. The command to set up the root password starts with set system, use ? to find the complete command. Finally, don’t forget to commit or your configuration will not be active!
root# set system ?
Possible completions:
> accounting           System accounting configuration
+ apply-groups         Groups from which to inherit configuration data
...
> tracing              System wide option for remote tracing
Also try out the help topic command to display usage guidelines (if you want the all story), the help reference command to display summary information (the most useful when you want to know about all command options) and the help apropos command which displays the contexts (typically set commands) relevant to the configuration hierarchy level at which you are currently positioned (if you want help only for your current hierarchy level and nothing else).
[edit]
root# help topic system root-authentication
root# help reference system root-authentication
root# help apropos root-authentication

Exercise 2 – host-name

Have you noticed? We have exactly the same prompt on both routers; this is annoying as we want to know which is which. Let’s add a host-name for both routers. We’ll let you find the right command (hint: use set system ?)

Solution

Now compare the candidate configuration with the active configuration using show | compare. The + are lines that are going to be added to the active configuration when you commit and – lines are going to be removed.  This is very useful to know exactly what is about to be changed. Do it on both routers and commit.
root# show | compare
[edit system]
+  host-name JUNOS1;
[edit]
root# commit
commit complete

Exercise 3 – rollback

On JUNOS2, configure a wrong hostname, anything. Commit your configuration and rollback to the one containing the right hostname.

Solution

Exercise 4 – edit

Let’s configure an IP address for the first interface on our JUNOS1 router using the edit command. Place yourself at the following level:interfaces em0 unit 0 family inet. em0 is the name for our first interface, give it this IP address and mask: 192.168.1.1/24

Solution

Exercise 5 – up

Go back up 3 levels and edit em1 in the same way as em0. Configure the following IP address and mask: 10.1.1.1/8

Solution

Exercise 6 – top & commit check

Go to the top level, check your configuration and commit.

Solution

Exercise 7 – set vs. edit & set

Configure the em0 (logical unit 0, IPv4 family) interface on JUNOS2 router with 192.168.1.2/24 IP address using the set command from the top level (remember ? is your friend).

Solution

Configure IP address 10.1.1.2/8 on em1 by placing yourself to the last level using edit.

Solution

Exercise 8 – telnet

Now we would like to configure telnet (SSH would be a better choice as it is secured) to remotely configure JUNOS2 from JUNOS1. First check that nothing is configured under system services level while staying at your current level (hint: use top). Then edit that level without going back to the top level. Configure telnet with the set command, exit to the top level, check what you are about to change and finally commit.

Solution

Add a user account to access this device using telnet and commit again.

Solution

Exercise 9 – run

Back to JUNOS1, without leaving configuration mode, ping and telnet to JUNOS2 (IP address: 192.168.1.2). Use Ctrl + C to stop pinging. Use the username and password you previously created to authenticate with JUNOS2.

Solution

Exercise 10 – automatic rollback

From your telnet session on JUNOS2, delete the telnet statement under system services level and commit in a way that if you lose your connection to JUNOS2, the configuration is automatically rolled back after 1 minute. Exit both configuration and operational modes to go back to JUNOS1. Try to telnet again to 192.168.1.2; this should not work. Wait about 2 minutes (take a coffee break) and try again. This time it should work as your previous commit should have been rolled back.

Solution

Exercise 11 – copy & rename

Copy em1 configuration to em2 and rename em2 to em3. Deactivate em3. Go to interfaces level and display the candidate configuration. Note the inactive: em3. Finally commit.

Solution

Change em3 IP address from 10.1.1.1/8 to 10.1.1.3/8 (hint: use the rename command). Maybe you would like to see what commands produced this candidate configuration? Use show and a pipe to find out.

Solution

Exercise 12 – annotate

Add an annotation saying that em3 is inactive. Using only one command, commit with a comment describing what you just did and return to operational mode.

Solution

Compare the active configuration with the previous one using the show configuration command.

Solution

Exercise 13 – rescue

You know your configuration works well (basic connectivity is established for instance). Therefore you want to make it the rescue configuration in case of problem; this will speed up a recovery. Create the rescue configuration and restore it.

Solution

Exercise 14 – preferred IP address

Configure an additional IP address (192.168.1.3/24) for em0 and configure your router so that it uses this IP as the source when sending pings to JUNOS2. Commit, exit to operational mode and check with the show interfaces command that em0 has 2 IP addresses.

Solution

Let’s check that JUNOS1 can actually send packets using source IP address 192.168.1.3. On JUNOS2, in operational mode, use the following command to monitor the traffic to and from the router:  monitor traffic interface em0 (Ctrl + C to exit). Then ping from JUNOS1 to 192.168.1.2. You should see that you are receiving packets from 192.168.1.3 (192.168.1.3 > 192.168.1.2)
root@JUNOS1> ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=12.510 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=1.665 ms
root@JUNOS2> monitor traffic interface em0
verbose output suppressed, use <detail> or <extensive> for full protocol decode
Address resolution is ON. Use <no-resolve> to avoid any reverse lookup delay.
Address resolution timeout is 4s.
Listening on em0, capture size 96 bytes
04:37:18.543830 192.168.1.3 > 192.168.1.2: ICMP echo request, id 40718, seq 12, length 64
04:37:18.544023 192.168.1.2 > 192.168.1.3: ICMP echo reply, id 40718, seq 12, length 64
Congratulations, you completed this page! If you are ready to have some more, please go to Secondary System Configuration

Tuesday, 15 January 2013

[Video] - Step By Step Guide To Install JunOS on GNS3

Note: Steps by Steps video guide to install JunOS 10.1 in Qemu for GNS3 for Juniper router simulation can be viewed at the end of this post.
Download the required software
1. JunOS 10.X (use Torrents may OS Image are available from there i also got)
Link
2. Download FreeBSD 4.11 as base OS for Router Download
3. Download Qemu 0.11.0 from GNS3 web site Download
4. Need to Software to create CD ISO image. ex:
Deep Burner

Time to Start
Step 1: Download all the given files above
Step 2: Extract Qemu in a folder
Step 3: Open cmd and navigate to extracted folder
Step 4: Create a HDD image to install JunOS of 4GB

qemu-img.exe create j.img -f qcow2


Step 5:
Start the Qemu with Free BSD CD and Created HDD

qemu.exe -L . -m 256 -hda j.img -boot d -localtime –cdrom ..\4.11.4.11-RELEASE-i386-miniinst.iso


Step 6:
Install Free BSD in Qemu
Skip Kernel configuration
Choose standard installation
With fdisk, press A to allocate entire disk for bsd
Select: install a standard MBR
Create partition (with C)
512M for /
1024M for swap partition
128M for /config
and the rest for /var
Choose installation type: user, and select No for FreeBSD ports
X to Exit the menu and install from CD/DVD
Wait until it's done
Yes for chance to set any last options
Type root password
Select 'X' to Exit the installation, it will reboot
while it's rebooting, exit from Qemu by pressing Ctrl-Alt-2,
then type: q

Step 7:
Make JunOS ready to transfer in guest OS
Create a CD Image (ISO) of junOS (using deepburner or any of it kind) and save in Qemu Folder with name like j8.iso
 

Step 8:
Make JunOS Ready for Installation

qemu -L . -m 512 -boot c -hda j.img –cdrom j8.iso

We need to untar the signed jinstall file first:


#mount /cdrom
#cd /var/tmp
#mkdir junos
#cd junos
#tar zxvf /cdrom/jinstall-10.1R1.8-domestic-olive.tgz
Then untar the unsigned image:
#mkdir jinst
#cd jinst
#tar zxvf ../jinstall10.1R1.8-domestic.tgz
Extract the pkgtools.tgz file and replace the checkpic binary inside with /usr/bin/true :
#mkdir pkgtools
#cd pkgtools
#tar zxvf ../pkgtools.tgz
#cd bin
#cp /usr/bin/true ./checkpic
#cd ..
Create tar for pkgtools then remove the directory:
#tar zcvf ../pkgtools.tgz *
#cd ..
#rm -rf pkgtools
Create tar for the new jinstall package with modified checkpic
#tar zcfv /var/tmp/j.tgz *
Then install the new jinstall with bsd pkg_add tool:
#pkg_add -f /var/tmp/j.tgz


It will ask to reboot to continue the installation.
One installation is finished and prompt is returned press Crtl+Alt+2 then type “q” press enter

Step 9:
Install JunOS in Guest VM

“qemu -L . -m 512 -hda j.img -serial telnet:127.0.0.1:1001,server,nowait,nodelay –localtime”

open new cmd and do telnet to 127.0.0.1 to enjoy the watching installtion process of JunOS
Once Prompt appear type cli to start junOS configuration

Step By Step Guide To Install JUNOS on GNS3 [Part 3]

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

request system software add [jinstall_package]


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:

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).

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


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.

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 inter face 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 yourolive using a TAP interface.

Testing
To check if everything work, let’s configure 2 Olives:

root@%cli
root>edit
[edit]
root#

[edit]
root#set system root-authentication plain-text-password
New password:
Retype new password:

[edit]
root#set interfaces em0 unit 0 family inet address 10.0.0.1/8
[edit]
root#commit
commit complete

Configure the other device using the same commands but with another IP address (e.g. 10.0.0.2/8) and ping.

root#exit
Exiting configuration mode
root> ping 10.0.0.2
PING 10.0.0.2 (10.0.0.2): 56 data bytes

64 bytes from 10.0.0.2: icmp_seq=0 ttl=64 time=9.771 ms
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.614 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.693 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.630 ms


Additionally, configure OSPF (or any other multicast based protocol) to test if your routers can talk to each other using multicast packets. Again, type those commands on both routers:

root# set protocols ospf area 0 interface em0

[edit]
root# commit
commit complete

[edit]
root# exit
Exiting configuration mode

Then monitor the traffic from one of the router, you should see some multicast traffic (from/to 224.0.0.5):

root> monitor traffic interface em0

02:30:30.973748 Out IP 10.0.0.1 > 224.0.0.5: OSPFv2, Hello, length 48
02:30:31.007675 In IP 10.0.0.2 > 224.0.0.5: OSPFv2, Hello, length 48


Is everything working? yes? then you are successfully running JunOS! Happy networking

What is working
Here is a list of what has been tested and works. You can extend this list by posting comments on what is working or not for you and I’ll update the list:

                                                OSPF (fxp0) OK                            
                                                OSPF (em0) OK                            


A few words about the patch By default using JunOS with a non-patched Qemu, multicast based protocols didn’t worked. As I have very little driver coding experience (and time to learn), I patched Qemu to allow multicast frames to be received by JunOS, instead of being filtered at the driver level multicast frames are filtered by JunOS. The only problem I see could be on the performance side, as JunOS receives every multicast frames, even those not destined to it. However, I think this is not an issue for a simulated lab environments and it worked just fine so far.
If you feel you can do something cleaner, please don’t hesitate, you can still read one of the
Intel manuals concerning the e1000 to have an overview of how complicated driver programming can be.

Conclusion
If you are IT guy (hope you are if you want to play with JunOS), you should be able to run JunOS on your PC without too many issues. I wrote this howto to be as complete as possible, showing how to compile and patch Qemu on 3 different operating systems, installing FreeBSD and JunOS. I encourage everyone to contribute to it by providing fixes, comments or any other help.