labbing

Configuring DHCP on a Cisco Switch

Today we are going to create a DHCP pool, specifying the required parameters for a example network

  • First we need to establish a connection to the switch via telnet, ssh or a console cable.
Switch> enable
Password: [Enter your password]
  • Second we need to enter privileged EXEC mode and then enter global configuration mode
Switch# configure terminal
Switch(config)#
  • Third we need to create a DHCP pool name and then assign our network address and subnet mask. You will want to replace [POOL_NAME], [NETWORK_ADDRESS] and [SUBNET_MASK] with your own options.
Switch(config)# ip dhcp pool [POOL_NAME]
Switch(dhcp-config)# network [NETWORK_ADDRESS] [SUBNET_MASK]
  • Our fourth setup will be assigning a default router (gateway) and DNS server options.
Switch(dhcp-config)# default-router [ROUTER_ADDRESS]
Switch(dhcp-config)# dns-server [DNS_SERVER1_ADDRESS] [DNS_SERVER2_ADDRESS]

Just like above you will want to replace [ROUTER_ADDRESS], [DNS_SERVER1_ADDRESS] and [DNS_SERVER2_ADDRESS] options with your own parameters.

  • Optionally, we might want to specify a domain name, lease duration and possibly exclude some IP addresses from the network you configured.
Switch(dhcp-config)# domain-name [YOUR_DOMAIN_NAME]
Switch(dhcp-config)# lease [DAYS] [HOURS] [MINUTES]
Switch(config)# ip dhcp excluded-address [START_IP_ADDRESS] [END_IP_ADDRESS]

Remember to replace to objects in [ ] with your own options.

Below you will find a example of all the options with realistic configuration for a small local network.

Switch(config)# ip dhcp pool Unreal_DHCP
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 8.8.8.8 8.8.4.4
Switch(dhcp-config)# domain-name unreallabs.local
Switch(dhcp-config)# lease 1 * *
Switch(dhcp-config)# exit
Switch(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
Switch(config)# end
Switch# write memory

After these steps, the switch will now serve DHCP requests with the defined configurations. Please note that for a switch to effectively act as a DHCP server, it must have IP routing capabilities or be a multi-layer switch. I have also posted a video from our YouTube channel @unreal-labs. Thanks for reading and check back in soon!

DHCP on Cisco Switches