Let’s say we need to setup a quick DHCP server on IOS and JunOS.
We’ve been tasked with configuring DHCP to give out addresses in the 192.168.1.0/24 subnet, but only from 192.168.1.2 to 192.168.1.100.
We’ve also been asked to not give out 192.168.1.50 as this has been hardcoded in the local fileserver. The lease time should only be 1 hour, and the default gateway should be 192.168.1.1
This is how we do it on the IOS we know and love:
>conf t #ip dhcp pool 192.168.1.0/24 #network 192.168.1.0 255.255.255.0 #default-router 192.168.1.1 #lease 0 1 #exit #ip dhcp excluded-address 192.168.1.101 192.168.1.255 #ip dhcp excluded-address 192.168.1.1 #ip dhcp excluded-address 192.168.1.50
Now on JunOS:
> configure # edit system service dhcp # set default-lease-time 3600 # set router 192.168.1.1 # set pool 192.168.1.0/24 address-range low 192.168.1.2 high 192.168.1.100 # set pool 192.168.1.0/24 exclude-address 192.168.1.50
There are extra things you can add to both, like domain name and so on, but I wanted a quick and dirty comparison between the 2. Remember that you will need an interface in the scope on either router in order for DHCP to actually work.
Let’s now say that we do have a DHCP server. This server is on another subnet, and so DHCP requests won’t get through (as they are broadcasted). Consider the following topology:
Both IOS and JunOS allows you to configure the router as a DHCP relay agent. This is how it’s done.
On IOS it’s extremely simple. All you need to do is put the following command on the interface receiving the broadcast. In this topology it’ll be the interface connected to the switch and workstation the user is on
>conf t # int fa0 # ip helper-address 10.1.1.1
On JunOS it’s just as simple. The configuration is not put on a particular interface, rather you specify which interface will be receiving the broadcast.
> configure # set forwarding-options helpers bootp interface em1 # set forwarding-options helpers bootp server 10.1.1.1
Nice and easy :)
Let’s set up a basic OSPF adjacency between JunOS and IOS. I’ve got the following simple topology:
The good thing here is that the configs shown will show the difference between JunOS and IOS as the actual configuration goal is the same for both.
The Cisco config is as follows:
Router>conf t #int fa0 #ip address 192.168.1.2 255.255.255.0 #int lo100 #ip address 172.16.10.1 255.255.255.0 #router ospf 1 #network 192.168.1.0 0.0.0.255 area 0 #network 172.16.10.0 0.0.0.255 area 0 #exit
Now onto JunOS:
root@Olive>configure # set interfaces em1 unit 0 family inet address 192.168.1.2/24 # set interfaces lo0 unit 100 family inet address 172.16.20.1/24 # edit protocols ospf area 0 # set interface 192.168.1.1 # set interface 172.16.20.1
Let’s see what we see on the Cisco:
Router#sh ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 172.16.20.1 128 FULL/BDR 00:00:34 192.168.1.1 FastEthernet0 Router#sh ip route 172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks O 172.16.20.0/24 [110/1] via 192.168.1.1, 00:00:25, FastEthernet0 O 172.16.20.1/32 [110/1] via 192.168.1.1, 00:00:25, FastEthernet0 C 172.16.10.0/24 is directly connected, Loopback100 C 192.168.1.0/24 is directly connected, FastEthernet0
What about the Olive?
root@Olive> show ospf neighbor Address Interface State ID Pri Dead 192.168.1.2 em1.0 FULL 172.16.10.1 1 36 root@Olive>show route 172.16.10.1/32 *[OSPF/10] 00:09:05, metric 2 > to 192.168.1.2 via em1.0
And yes, both routers can ping both loopbacks :)
Right, it’s really time I get cracking on with my JNCIA. I’m going to do the EX track first, then maybe ER as well.
I’ve set up an Olive quickly and connected it to a 1721 via dynamips. I want to start off with the basics of getting around the cli of JunOS. Yes it’s different to IOS, but it’s really not that difficult.
When the Olive first boots up, it’ll be a blank slate. If you logged in as root, you’ll need to enter cli to actually get to the cli:
Right, now we are at the CLI. Let’s start configuring!
First go into configure mode:
root@O> configure Entering configuration mode  root@O#
Let’s start with a few basics. These few are all intuitive:
#set system host-name Olive #set system time-zone Europe/London #set system domain-name test.com #set system name-server 22.214.171.124
Note that JunOS won’t make these changes live straight away. All changes go into a ‘candidate configuration’ – Only when you actually commit the changes will they actually happen. You can commit straight away or do a syntax check beforehand:
#commit check configuration check succeeds
This means all looks good, so let’s commit the changes!
#commit commit complete  root@Olive#
There is something to note here. JunOS’s config mode is hierarchical. This means that if I was going to do a lot of commands in the same sub-section – I could go into that sub-section first.
For example, the above 4 commands were all in the system sub-section. Instead of the above, I could’ve done this:
root@O> configure Entering configuration mode  root@O#edit system [edit system] root@O#set host-name Olive #set time-zone Europe/London #set domain-name test.com #set name-server 126.96.36.199
This would give me exactly the same configuration as the above. If I need to get out of a sub-section I just type ‘up’
#up  root@O#
If I’m in pretty deep, you can type ‘top’ to get right to the top of the tree
Now we need to set up an IP address on an interface. To see what interfaces you have, you can type:
Olive> show interfaces terse
This command is similar to show ip int brief on a Cisco
I want to configure the em1 interface and I do so like this:
Olive# set interfaces em1 unit 0 family inet address 10.1.1.1/28
So quite a bit longer than on a Cisco, but it’s really not that difficult. There is an important note here. When you assign an IP address to a Cisco, it becomes the ‘first’ IP. You can add secondary addresses on that interface but you need to specify secondary when entering the IP address. The same thing happens on JunOS, but you HAVE to specify a logical unit at all times, even if it is only EVER going to have 1 IP. Therefore Unit 0 is the first IP, unit 1 the second, unit 2 the third and so on. If I wanted to add a second IP to this interface, I’d do it like so:
Olive# set interfaces em1 unit 1 family inet address 10.2.2.2/28
To set up a default route, we do it like so:
Olive# set routing-options static route 0.0.0.0/0 next-hop 10.1.1.2
There’ll be plenty more JunOS stuff coming very shortly!