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 [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. |