0% found this document useful (0 votes)
151 views

How To Configure DHCP Server On Cisco Switches

This document explains how to configure a Cisco switch as a DHCP server to assign IP addresses to network hosts. It provides the commands needed, such as to create a DHCP pool, define the IP range, set default gateway and DNS server addresses. An example configuration on Packet Tracer is shown, where the switch is configured with a DHCP pool for VLAN 1. Hosts are set as DHCP clients and are successfully assigned IP addresses from the switch DHCP server, which can be verified through IP configuration displays and the 'show ip dhcp binding' command.

Uploaded by

肯恩
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views

How To Configure DHCP Server On Cisco Switches

This document explains how to configure a Cisco switch as a DHCP server to assign IP addresses to network hosts. It provides the commands needed, such as to create a DHCP pool, define the IP range, set default gateway and DNS server addresses. An example configuration on Packet Tracer is shown, where the switch is configured with a DHCP pool for VLAN 1. Hosts are set as DHCP clients and are successfully assigned IP addresses from the switch DHCP server, which can be verified through IP configuration displays and the 'show ip dhcp binding' command.

Uploaded by

肯恩
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

How to Configure DHCP Server on Cisco

Switches
This tutorial explains how to configure the DHCP service on a Cisco switch through a
packet tracer example. Learn how to use a Cisco switch to act as the DHCP server.
The DHCP service allows hosts to automatically obtain their IP configuration from
the DHCP server. The DHCP service is available on Cisco switches. This means, 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 To create a range of excluded IP


[starting address] [ending address] addresses.

Switch(config)#ip dhcp pool [pool name] To create a DHCP pool and enter
DHCP pool configuration mode.

Switch(dhcp-config)#network [network To define the range of IP addresses


ID] [subnet mask] that the DHCP server should offer to
clients.

Switch(dhcp-config)#default-router [IP To set the IP address of the default


address of default gateway] gateway.

Switch(dhcp-config)#dns-server [IP To set the IP address of the DNS


address of DNS server] 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 To set an IP address on the VLAN1.
available IP address from the pool]
[subnet mask]

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 To copy running configuration to startup


startup-config configuration.
Before we take a packet tracer example to understand 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.

This tutorial is the fourth part of the article 'DHCP (Dynamic Host Configuration
Protocol) basic concepts, configurations, functions, and options
Explained'. Other parts of this tutorial are the following.

What DHCP is and Types of DHCP Explained

How DHCP works explained with examples

DHCP Configuration Parameters and Settings Explained

Configure DHCP Server for multiple VLANs on the Switch

How to Configure DHCP Server on Cisco Routers

How DHCP Relay Agents work Explained

How to Configure DHCP Relay Agent on Cisco Routers

How DHCP Snooping works Explained

Configure DHCP Snooping on Cisco Switches

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.

Objective
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>enable
Switch#configure terminal
Switch(config)#ip dhcp excluded-address 192.168.1.1
192.168.1.10
Switch(config)#ip dhcp pool test
Switch(dhcp-config)#network 192.168.1.0 255.255.255.0
Switch(dhcp-config)#default-router 192.168.1.1
Switch(dhcp-config)#dns-server 4.4.4.4
Switch(dhcp-config)#exit
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.1.5 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#exit
Switch#

The following image shows how to execute the above commands on the switch.
Let's understand the above configuration.
First, we created a range of reserved IP addresses (192.168.1.1 - 192.168.1.10). 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 (192.168.1.0 255.255.255.0). 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 the 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 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.

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.
Viewing leased addresses and DHCP statistics
To view IP addresses leased by the DHCP server, use the 'show ip dhcp binding'
command in privileged-execution mode.
The following image shows the output of this 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.
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. If you like this tutorial,
please don’t forget to share it with friends through your favorite social network.

You might also like