Saturday, February 5, 2011

JunOS vs IOS – DHCP


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

No comments:

Post a Comment