Cisco IOS has a DHCP server feature that lets you configure a router as a DHCP server and assign IP addresses to clients connected to it from specified address pools.
A Cisco router can either be the primary DHCP server or one of the secondary DHCP servers.
It is also possible to configure an interface on a Cisco router to be a DHCP client and get IP address from a DHCP server.
The following is a sample configuration of a Cisco 2600 router R1 as DHCP server
The network is 172.20.1.0/24
The DHCP server IP is 172.20.1.1
The 10 addresses from 172.20.1.1 to 172.20.1.9 are reserved and not to be assigned to DHCP clients hence these have to be excluded from the DHCP pool.
Step 1: Configure one interface on R1 with IP address 172.20.1.1
R1# configure terminal R1(config)# interface fastethernet0/0 R1(config-if)# ip address 172.20.1.1 255.255.255.0 R1(config-if)# no shutdown R1(config-if)# exit
Step 2: Configure DHCP
R1(config)# ip dhcp excluded-address 172.20.1.1 172.20.1.9 R1(config)# ip dhcp pool MY_POOL R1(dhcp-config)# network 220.127.116.11 255.255.255.0 R1(dhcp-config)# default-router 18.104.22.168 R1(dhcp-config)# dns-server 22.214.171.124 R1(dhcp-config)# domain-name opentechguides.com R1(dhcp-config)# exit
The commands to configure DHCP client on a router interface are
RouterA# configure terminal RouterA# interface fastethernet0/0 RouterA# ip address dhcp RouterA# no shutdown