How to Configure DHCP Server on Cisco Switches

The DHCP service allows hosts to automatically obtain their IP configuration from the DHCP server. The DHCP service is available on Cisco switches. If you have a Cisco switch in your network, you can also use it as a DHCP server.

The following table lists the commands that are required to configure a switch to act as a DHCP server.

Command Description (command used for)
Switch>enable To enable the switch and to enter privileged-exec mode.
Switch#configure terminal To enter global configuration mode.
Switch(config)#ip dhcp excluded-address [starting address] [ending address] To create a range of excluded IP addresses.
Switch(config)#ip dhcp pool [pool name] To create a DHCP pool and enter DHCP pool configuration mode.
Switch(dhcp-config)#network [network ID] [subnet mask] To define the range of IP addresses that the DHCP server should offer to clients.
Switch(dhcp-config)#default-router [IP address of default gateway] To set the IP address of the default gateway.
Switch(dhcp-config)#dns-server [IP address of DNS server] To set the IP address of the DNS server.
Switch(dhcp-config)#exit To exit DHCP pool configuration mode.
Switch(config)#interface vlan 1 To enter VLAN configuration mode of the VLAN 1.
Switch(config-if)#ip address [any available IP address from the pool] [subnet mask] To set an IP address on the VLAN1.
Switch(config-if)#no shutdown To enable the VLAN.
Switch(config-if)#exit To exit VLAN configuration mode.
Switch(config)#exit To exit global configuration mode.
Switch#copy running-config startup-config To copy running configuration to startup configuration.

Before we learn how to use the above commands in detail, I assume that you are familiar with DHCP terminology and configuration. To know what DHCP is and how it works, please check the previous parts of this tutorial.

DHCP configuration on Cisco switches (Packet Tracer example)

Either download the following pre-created practice lab or create a packet tracer lab to replicate the network explained below.

Download link of the pre-created practice lab

In a small network, a Cisco switch and a generic wireless access point are used to provide connectivity between hosts. Wired hosts are directly connected to the switch. Wireless hosts are connected to the access point and the access point is connected to the switch.

The following image shows this network.

packet tracer lab for practice


Configure the switch to act as the DHCP server.

Configuring DHCP service on the switch

Access the command prompt of the switch and run the following commands.

Switch#configure terminal
Switch(config)#ip dhcp excluded-address
Switch(config)#ip dhcp pool test
Switch(config)#interface vlan 1
Switch(config-if)#ip address
Switch(config-if)#no shutdown

The following image shows how to execute the above commands on the switch.

commands to configure switch as dhcp server

Let's understand the above configuration.

First, we created a range of reserved IP addresses ( - We use reserved addresses for the resources that need a static IP configuration such as routers, servers, and printers, etc.

After this, we created the pool named test and defined a range of all available IP addresses ( This IP range also includes the reserved IP addresses that we excluded in the first step.

When the DHCP server provides IP addresses, it automatically excludes the reserved IP addresses from all available IP addresses.

Then, we set the default gateway and DNS server IP addresses.

Finally, we assigned an IP address from the reserved IP address to the Vlan 1 and enabled the Vlan 1.

DHCP uses the source IP address to determine the pool from which it should offer the IP address. Since a DHCP client does not have an IP address, DHCP uses the client's Vlan IP address to determine the IP pool for it.

The client's Vlan is the Vlan that is configured on the switch port that is connected to the client. For example, if a client is connected to the port F0/5 and Vlan 10 is configured on the port F0/5, then the client's vlan will be Vlan 10.

By default, all switch ports belong to VLAN 1. This means, unless you create or configure additional VLANs, DHCP will use VLAN1's IP address to determine the pool.

Since we assigned an IP address to VLAN 1 from our configured pool and did not create any additional VLAN, DHCP will use our pool to assign IP addresses to all clients.

VLAN is a switch management feature. It allows us to manage switch remotely, categorize connected hosts, and do a lot of extra stuff. To learn more about the VLAN, you can check the following tutorial.
VLAN Basic Concept Explained with Examples

Configuring DHCP clients

To configure a host as a DHCP client, change the host's IP configuration option to DHCP. For this, click the device and click the Desktop option and click the IP configuration and select the DHCP option.

The following image shows this procedure step-by-step on packet tracer.

configure dhcp clients

Configure all hosts as DHCP clients by following the above-explained steps.

Verifying DHCP server

To verify that the switch is properly configured as a DHCP server, you can check the IP configuration of any connected host.

To view the IP configuration of any host, click the host and click the Desktop option and click the IP configuration option and check the obtained IP configuration.

The following image shows these steps.

verify dhcp client ip configuration

You can also use the 'ipconfig' command to view the IP address. To use the 'ipconfig' command, select the command prompt of the device and run this command.

The following image shows how to use this command.

verify dhcp server

Viewing leased addresses and DHCP statistics

To view IP addresses leased by the DHCP server, use the 'show ip dhcp binding' command in privileged-exec mode.

The following image shows the output of this command.

show ip dhcp binding command

To view DHCP pool statistics and information, use the 'show ip dhcp pool [pool-name]' command. The following image shows the output of this command.

show ip dhcp pool command

Configured packet tracer lab

The following download link provides the configured packet tracer lab of the example used in this tutorial.

Configured packet tracer lab of the example

That's all for this part. In the next part of this tutorial, we will understand how to configure and use multiple DHCP pools to support VLANs.

ComputerNetworkingNotes CCNA Study Guide How to Configure DHCP Server on Cisco Switches