DHCP server on Cisco

A pool per network, excluded addresses and fixed addresses by MAC.
Configuration for IOS and IOS XE — with check and undo.

DHCP server on Cisco

DHCP configuration for a Cisco IOS or IOS XE router or L3 switch: a pool per network, addresses that must not be handed out, gateway, DNS, domain, lease time, options 150 and 66 for IP phones and fixed addresses for chosen devices.

1. Networks and pools

Gateway is the router's interface address in that network with its prefix length; it defines the network. Excluded addresses are ranges with a hyphen, short form allowed: .1-.20. The gateway address is excluded automatically.

2. Fixed addresses

The device always gets the same address from the network that contains it. Any MAC format works: 00:11:22:33:44:55, 00-11-…, 0011.2233.4455.

Configuration

   
Check

   
Undo

   

The configuration is built in your browser; addresses and MACs are not sent anywhere.

How to set up DHCP on Cisco

A Cisco router or L3 switch can hand out addresses itself — no separate server needed. Each network gets a pool with its network address, gateway, DNS and lease time, and addresses taken by hand — the gateway, servers, printers — are excluded with ip dhcp excluded-address. Devices that need a fixed address get their own pool bound to their MAC.

How to use it

  1. Add networks: pool name, gateway address with prefix, addresses not to hand out, DNS and lease time. For an IP phone network, enter the TFTP server.
  2. Add devices that need a fixed address. If a device does not get its address by client-identifier, choose hardware-address.
  3. Paste the configuration in configure terminal mode and connect the device.
  4. Check with the commands from the “Check” block and save the configuration.

client-identifier or hardware-address

Most devices, Windows included, present themselves to a DHCP server with a client identifier: the MAC with a 01 byte in front, which is why the configuration writes it as 0100.1122.3344.55. Some access points, printers, cameras and Linux send only the MAC — they need a hardware-address line. If unsure, let the device take a dynamic lease and look at show ip dhcp binding: it shows how the device identified itself. Foreign DHCP servers are blocked by DHCP snooping on the switches — the “Cisco L2 security” page sets it up, together with bindings for IP Source Guard.

Frequently asked questions

Why exclude addresses if the pool already knows the gateway?

IOS does not know which addresses in the network are taken by hand: the gateway, servers, printers. Without an exclusion it may hand such an address to another device, causing a conflict. IOS pings an address before offering it, but a printer that is switched off does not answer.

Why does a device get a different address from the one I bound?

Usually an old lease is left: delete it with clear ip dhcp binding

and reconnect the device. If that does not help, the device identifies itself differently — check show ip dhcp binding and try hardware-address instead of client-identifier.

Can I hand out addresses in several VLANs?

Yes: create a pool per network. The router answers in the network where it has an interface with an address from the pool, such as a VLAN interface or subinterface. If the DHCP server is elsewhere, ip helper-address on the interfaces is enough.

What are options 150 and 66?

The address of the TFTP server IP phones download their settings and firmware from. Cisco phones read option 150, most other SIP phones option 66. The configuration sets both.

More tools

Cisco

Cisco port configuration
access, voice, trunk, Port Security for many ports
EtherChannel on Cisco
LACP, PAgP, trunk and commands for the other end
Cisco L2 security
DHCP snooping, DAI, IP Source Guard
Cisco SNMPv3
authPriv instead of communities, ACL, traps
Cisco config diff
Section by section, with draft commands
Cisco backups
A copy on every write memory and on a schedule
Cisco Type 7
Encode and decode password 7
Cisco config audit
Weak passwords, Telnet, SNMP and fixes