Cisco IOS DHCP Server: Pools, Exclusions and Options - 夜莺博客

Cisco IOS DHCP Server: Pools, Exclusions and Options

Small and remote sites often need DHCP without a dedicated server, and the DHCP server built into Cisco IOS is capable enough to serve a branch: address pools, exclusions for servers and routers, DNS/domain options and static reservations. The two mistakes that bite everyone are forgetting that excluded addresses are global (not part of the pool), and saving nothing - so the whole scope vanishes on reload. This guide configures a working Cisco IOS DHCP server with the classic commands.

Step 1: Exclude Addresses (Global, Not Per-Pool)

Anything that must never be leased - router interfaces, servers, printers - is excluded at global configuration level, outside any pool:

Router(config)# ip dhcp excluded-address 192.168.0.1 192.168.0.10
Router(config)# ip dhcp excluded-address 192.168.0.50
Router(config)# ip dhcp excluded-address 192.168.0.200 192.168.0.254

Note the interface IP of the router itself is always excluded automatically. This is the classic trap: engineers look for the exclusion inside the pool (like Windows Server scopes) and cannot find it - on IOS, exclusions are top-level commands.

Step 2: Define the Address Pool

Router(config)# ip dhcp pool LAN-COMPUTERS
Router(dhcp-config)# network 192.168.0.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.0.1
Router(dhcp-config)# dns-server 8.8.8.8 1.1.1.1
Router(dhcp-config)# domain-name example.com
Router(dhcp-config)# lease 7
Router(dhcp-config)# exit

The pool name can be a word or a number; entering it drops you into (dhcp-config)# mode. Typical pool options:

  • network - the subnet served, with mask.
  • default-router - gateway(s) handed to clients.
  • dns-server - one or more resolvers.
  • domain-name - DNS search suffix.
  • lease - days/hours/minutes (e.g. lease 0 12 0 for 12 hours).
  • netbios-name-server / netbios-node-type - legacy WINS options when still needed.

Step 3: Manual Bindings (Static Reservations)

Give a fixed address to a specific MAC (for example a management device) with a manual binding:

Router(config)# ip dhcp pool PRINTER-BINDING
Router(dhcp-config)# host 192.168.0.50 255.255.255.0
Router(dhcp-config)# client-identifier 01aa.bbcc.ddee.ff
Router(dhcp-config)# exit

The client-identifier is the MAC with a leading 01 (ARP media type) prefix; alternatively use hardware-address aabb.ccdd.eeff.

Optional: Split Subnets Across Two Servers

For redundancy without DHCP failover, two servers split the subnet with complementary exclusions:

! Server A
ip dhcp excluded-address 10.0.20.126 10.0.20.255
ip dhcp pool A
 network 10.0.20.0 255.255.255.0

! Server B
ip dhcp excluded-address 10.0.20.0 10.0.20.125
ip dhcp pool B
 network 10.0.20.0 255.255.255.0

Verification and Troubleshooting

Router# show ip dhcp binding          # active leases
Router# show ip dhcp pool             # pool config and utilization
Router# show ip dhcp server statistics
Router# debug ip dhcp server events   # watch DISCOVER/OFFER/REQUEST/ACK

Clients not getting addresses: check that the relay (if any) points at this router with ip helper-address (see our DHCP relay guide), that the pool subnet matches the client's broadcast domain, and that ip dhcp snooping (covered in our DHCP snooping article) is not dropping server replies on the path. For IPv6 networks the equivalent service is DHCPv6 or SLAAC - compared in our SLAAC vs DHCPv6 guide.

原文链接:https://www.cisco.com/en/US/docs/ios/12_4t/ip_addr/configuration/guide/htdhcpsv.html