Friday, 4 January 2013

DHCP Server configuration on a Cisco Router

Introduction 

DHCP (Dynamic Host Control Protocol) is a protocol used to provide network parameters (IP address, default gateway, DNS server etc.) to network devices (Computers, printers, switches etc.) so that they can communicate on an IP network. A DHCP client (eg. PC) uses the DHCP protocol to obtain the network configuration from the DHCP server (eg. Cisco Router).

How DHCP Works ?

DHCP client uses four phases to obtain network parameters from a DHCP server:
  1.  Discover : A client broadcast a DHCP discover message during its initial boot up. This is a broadcast message.
  2.  Offer : When the DHCP server receives the discover message, it reserves an IP address for  the client and sends a DHCP offer message to the client by offering the reserved IP. This is a unicast message.
  3. Request : The client receives the offer message and sends a request message requesting the IP address. This is again a broadcast message.
  4. Acknowledgement : The DHCP server sends the acknowledgement to the client which contain all the information about the network parameters. This is a unicast message.
Configuring DHCP on a Cisco Router

This configuration is based on a Cisco Router running with 15.x code.

Configuration Scenario

First we have to enable the DHCP service on the router. Use the command as below:

Router#configure terminal
Router(config)#service dhcp

Now create a DHCP pool that contains the pool of IP addresses that will be allocated to the clients:

Router(config)#ip dhcp pool MyDHCPPool
Router(dhcp-config)#network 172.16.0.0 255.255.0.0

Now provide the DHCP parameters that should be distributed to the DHCP clients (default-router, DNS server, lease duration) as below:

Router(dhcp-config)#default-router 172.16.0.1
Router(dhcp-config)#domain-name tony.com
Router(dhcp-config)#lease 15

Now if you want to exclude a range of IP addresses from being distributed via DHCP, use the below commands in global configuration mode:

Router(config)#ip dhcp excluded-address 172.16.0.1 172.16.0.20

Now you can assign IP addresses ranging from 172.16.0.1 to 172.16.0.20 statically.

There we finish the DHCP server configuration on a Cisco Router.

Verification

You can verify the DHCP operation of Cisco Router by using the below command:

Router#sh ip dhcp binding

No comments:

Post a Comment