How to Configure a Basic DHCPv4 Server

A Cisco router can be configured as a DHCPv4 server. The DHCPv4 server assigns and manages IPv4 addresses from specified address pools within the router to DHCPv4 clients. The steps for configuring DHCPv4 server on Cisco routers are the following:

Excluding IPv4 Addresses

The router configured as the DHCPv4 server assigns all IPv4 addresses in an address pool unless configured to exclude specific addresses. Typically, some IPv4 addresses in a pool are assigned to network devices manually. So, these addresses should be excluded from being assigned by the DHCPv4 server. To exclude particular addresses from being assigned by DHCPv4, use the following command.

ip dhcp excluded-address <FIRST_IP LAST_IP>

We can exclude a single address or a range of addresses using the first address and last address of the range. The addresses assigned to the router must be excluded including the servers, printers, and other devices that have been manually configured.

Creating a DHCPv4 Pool

After Excluding IP addresses create and define an IPv4 addresses pool to assign. The command for creating a DHCPv4 pool is ip dhcp pool <pool-name>. Create a pool with a meaningful name. The ip dhcp pool will also put the router into configuration mode. The prompt of the DHCPv4 mode is Router(dhcp-config)#.

Configuring other network Parameters

After creating a DHCPv4 pool and enter into the DHCPv4 mode, we configure several parameters. Some of these parameters are optional, while others must be configured. The address pool and default gateway router must be configured. The DNS server, domain name, DHCP lease duration and NetBIOS Wins server configuration are optional. The command for these parameters are the following:

Router(dhcp-config)# network <netwowrk address>

This command will attach the IP address pool to the DHCPv4 pool created earlier. The next compulsory command is defaulter-router. The command syntax is the following:

Router(dhcp-config)# default-router <Interface address>

Using the above command we configure the default router or default gateway for the network. Typically, the gateway is the LAN interface of the router closest to the client devices. Usually, one gateway is required for a network, but we can also configure multiple gateways.

The DNS server, domain name, DHCP lease duration and NetBIOS Wins server configuration are optional for DHCPv4. The commands for these optional parameters are following:

Router(dhcp-config)#dns-server <dns-ip-address>

Router(dhcp-config)#domain-name <name>

 Router(dhcp-config)#domain-name <name>

Router(dhcp-config)#lease {days [hours] [minutes]| infinite]}

Router(dhcp-config)#netbios-name-server [server-ip-address]

 DHCPv4 Example

A sample configuration with basic DHCPv4 parameters configured on router Router0, a DHCPv4 server for the LAN is shown in the Figure below.

How to Configure a Basic DHCPv4 Server 7

The DHCPv4 service is by default enabled on most of Cisco IOS, if someone needs to disable the DHCP service. To disable the service, use the no service dhcp command in global configuration mode. To re-enable the service use the service dhcp command in global configuration mode.

Verifying DHCPv4

In the above example, we have configured the DHCPv4 server on Router0. The DHCPv4 is configured to provide services of DHCPv4 to corresponding LAN. We can verify the DHCPv4 configuration using different commands.

We can use the show running-config command to displays the DHCPv4 configuration. We can also use the | pipe to display only the parameter associated with DHCPv4 configuration for example show running-config | begin dhcp. The figure below illustrates the output of this command.

How to Configure a Basic DHCPv4 Server 8

We can also verify the DHCP operation using the show ip dhcp binding command. You can see the output of this command in the figure below. The output of this command displays a list of all IPv4 address to MAC address bindings that have been provided by the DHCPv4 service.

How to Configure a Basic DHCPv4 Server 9

Another command for DHCP operation verification is show ip dhcp server statistics. This command verifies that messages are being received or sent by the router. This command also shows the counter about the number of DHCPv4 messages that have been sent and received.

We can also use the command show ip dhcp pool <pool-name>. The figure below illustrates the output of this command.

How to Configure a Basic DHCPv4 Server 10

We can also verify the DHCPv4 process from the computer running and connected to the DHCPv4 server. As shown in Figure below, using the ipconfig /all command we can verify the IP address information of the computer. If an IP address is issued on the computer, it will display the TCP/IP parameters.

How to Configure a Basic DHCPv4 Server 11

In the figure, you can see the output of ipconfig /all command. You can see that the computer issued IP address is and the DHCP server address It is automatically received, IPv4 address, subnet mask, default gateway, and DNS server address from that pool.