How to set up a DHCP server on Cisco routers

avril 21st, 2009 by Alexandre VIOT Leave a reply »

For this first article, we will see how to set up a DHCP service on Cisco routers.

DHCP Service (Dynamic Host Configuration Protocol)  allows users to obtain IP configuration automatically.

The DHCP  service is often coupled with DNS service on a dedicated server. However, it is possible to activate it on a router for a small network.

An configuration has an IP address, its subnet mask and others options. Forty of them are configurable such as the default gateway, DNS servers, domain name and WINS server.

A client has a configuration during a specified time, we call it: the lease.

Note : DHCP uses broadcast to communicate,  which means that the client’s request can’t cross a router (except explicit command).

Configuration

This is the network for the test:

schema11

Configuring the DHPC service in 4 steps :

  1. Creating a DHCP pool.
  2. Indicating a network.
  3. Settings options of pool.
  4. IP Exclusions

Step 1 :Creating a DHCP pool

The first step is to create a DHPC pool on the router. One pool includes addresses which will be distribute and its options.

To activate a pool on the router, in configuration mode:

ip dhcp pool pool_name

pooldhcp

Once this done, we are in dhcp configuration mode.

It is possible to create several pool on the same router.

Step 2 : Indicating a network.

In dhcp configuration mode, to specify the network we use the command:

network ip_address mask

network

In this example, the service assigns ip addresses between 192.168.20.1 and 192.168.20.254

Step 3 :Settings options of pool.

We will specify 4 options : the default gateway, DNS server, the domain name et the lease.

To specify the default gateway, we use the option:

default-router ip_gateway

To indicate DNS server:

dns-server ip_server_DNS

The domain name is specified with:

domain-name domain_name

To configure  time of the lease : 

lease day hour minute

The option lease infinite permits to define a infinite lease.

DHCP Options

Step 4 : IP Exclusions

Once we have configured one or more pool DHCP on the server, we must define  ip addresses which will not use. To avoid conflicts with statics addresses.

How forbid the server to distribute router’s ip?

We use this command:

ip dhcp excluded-address ip_forbidden

DHCP excluded Address

3) DHCP Server Management

By default, the service DHCP is activated when we define a pool.

If we want to desactivate, we use the next command : no service dhcp. To reactivate : service dhcp

We can see distributed leases by the server with : show ip dhcp binding

DHCP Binding

Advertisement

3 comments

  1. Paul dit :

    Hi, interesting post. I have been thinking about this issue,so thanks for posting. I’ll definitely be coming back to your blog.

  2. KrisBelucci dit :

    Great post! Just wanted to let you know you have a new subscriber- me!

  3. CrisBetewsky dit :

    You know, I don’t read blogs. But yours is really worth beeing read.

Laisser un commentaire