web analytics

How to configure a Cisco switch to act as the DHCP server

This tutorial explains how to configure the DHCP service on a Cisco switch.

CONFIGURATION STEPS :

Step 1Enter into Global Configuration modeSW1>enable SW1#configure terminal
Step 2Create a range of excluded IP ranges from the subnet which you don’t want to allocate for end user devicesSW1(config)#ip dhcp excluded-address [start address] [end address]
Step 3Create a DHCP pool with the intended name. With this command, you will now Enter into the DHCP pool configuration modeSW1(config)#ip dhcp pool [pool-name]
Step 4Define the network and subnet maskSW1(dhcp-config)#network [network ID] [subnet mask]
Step 5Define the default gatewaySW1(dhcp-config)#default-router [IP address of default gateway]
Step 6Specify the DNS serverSW1(dhcp-config)#dns-server [IP address of DNS server]
Step 7Exit DHCP pool configuration modeSW1(dhcp-config)#exit
Step 8Enter VLAN configuration mode of the VLAN (VLAN 1 is used here as an example)SW1(config)#interface vlan 1
Step 9Configure an IP address (from the same range) to the VLAN interfaceSW1(config-if)#ip address [ip address] [subnet mask]
Step 10Bring up the VLANSW1(config-if)#no shutdown
Step 11Exit to privileged-exec modeSW1(config-if)#exit SW1(config)#exit
Step 12Save the  configuration.SW1#copy running-config startup-config

Example Configuration:

Verifying the DHCP IP lease from PC1