In my previous Junos Basics post I covered a simple OSPF configuration in Junos. In this post I’ll step through configuring a Juniper EX2200C switch as a DHCP server.
The EX2200C is a great little switch that’s ideal for a small branch office deployment, and one feature that you might look to take advantage of in such a network is the switch’s ability to function as a DHCP server.
The first step is to enable DHCP for a VLAN (in this case the SALES VLAN 192.168.1.0/24 that we created in a previous post):
set system services dhcp pool 192.168.1.0/24
Next, we’ll set the range of addresses that the server can dish out to clients to 192.168.1.10 – 100:
[edit system services dhcp pool 192.168.1.0/24] set address-range low 192.168.1.10 set address-range high 192.168.1.100
Then we need to make sure our DHCP clients pick up the correct domain name, DNS server and default gateway IP addresses:
[edit system services dhcp pool 192.168.1.0/24] set system services dhcp pool 192.168.1.0/24 domain-name small.biz set system services dhcp pool 192.168.1.0/24 name-server 192.168.1.1 set system services dhcp pool 192.168.1.0/24 router 192.168.1.1
That’s the basic configuration done so I’ll test it with a client machine connected to the SALES VLAN, and run a couple of show commands to verify our config is working:
To see stats for the client to server DHCP packets:
rich@EX2200C> show system services dhcp statistics Packets dropped: Total 0 Messages received: BOOTREQUEST 0 DHCPDECLINE 0 DHCPDISCOVER 1 DHCPINFORM 0 DHCPRELEASE 0 DHCPREQUEST 2 Messages sent: BOOTREPLY 0 DHCPOFFER 1 DHCPACK 2 DHCPNAK 0
To view the IP address leases:
rich@EX2200C> show system services dhcp binding IP address Hardware address Type Lease expires at 192.168.1.66 00:26:6c:10:6d:ff dynamic 2012-06-09 21:59:33 UTC
Finally, sometimes it is useful for a client machine to always receive the same IP address when it requests one from a DHCP server. This is achieved with a DHCP address reservation for the MAC address of the client machine.
To do this we have to go up a level in the configuration, and then set a static binding:
[edit system services dhcp] set static-binding 00:26:6c:10:6d:ff fixed-address 192.168.1.10
To test this I’ll release/renew the IP address on the client machine, and then check the binding on the server:
rich@EX2200C> show system services dhcp binding IP address Hardware address Type Lease expires at 192.168.1.10 00:26:6c:10:6d:ff static never
I hope this has been a useful explanation. In my next Junos Basics post I’ll cover automatic configuration archiving to an FTP server.
Thanks for reading.
Follow Rich on Twitter