Picture
Requirement:
Bat-man router F0/0 should get IP address from DHCP server configured on DHCP-Switch. Let's see how we can do it

Device Configuration

! batman-router
interface FastEthernet0/0
ip address dhcp
speed 100
full-duplex
no shut


! DHCP-SWITCH Configuration
hostname DHCP-SWITCH

interface fastEthernet 1/0
no shut
speed 100
duplex full
switchport access vlan 5

int vlan 5
ip add 20.10.10.1 255.255.255.0
no shut
exit

ip routing
ip dhcp excluded-address 20.10.10.1 20.10.10.3



ip dhcp pool dhcp-pool
network 20.10.10.0 255.255.255.128
default-router 20.10.10.1


domain-name dhcp.com.pk
lease 1 12



Explanation



Assign IP address via DHCP. When DHCP client will boot, the client will begin sending packets to its default router. The IP address of the default router should be on the same subnet as the client.



Changing Host name

This is a switch interface



Creating vlan. We will assign this vlan ip as adefault gateway address

Assigning ip to SVI interface




Address to exclude from ip pool. Actually we are already using or have to use these addresses in future and we donot want dhcp to assign these ip addresses to any other client
Assigning dhcp pool name
Assigning ip addresses to dhcp pool
This command will make 20.10.10.1 as a default gateway and propagate this information to all neighbors
Assigning domain name
IP lease time is 1 day and 12 hours

Verification of DHCP IP assignment and detailed debugging

batman-router#sh ip route

Gateway of last resort is 20.10.10.1 to network 0.0.0.0
Have you noticed gateway of last resort. This is due to default-router command configured on dhcp-switch
     20.0.0.0/25 is subnetted, 1 subnets
C       20.10.10.0 is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [254/0] via 20.10.10.1
Have you noticed default route. This is due to default-router command configured on dhcp-switch



batman-router#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            20.10.10.5      YES DHCP   up                    up



batman-router#debug dhcp detail

*Mar  1 00:17:37.179: DHCP: DHCP client process started: 10
*Mar  1 00:17:37.211: RAC: Starting DHCP discover on FastEthernet0/0
*Mar  1 00:17:37.211: DHCP: Try 1 to acquire address for FastEthernet0/0
*Mar  1 00:17:37.239: DHCP: allocate request
*Mar  1 00:17:37.243: DHCP: zapping entry in DHC_PURGING state for Fa0/0
*Mar  1 00:17:37.243: DHCP: deleting entry 673E86B4 20.10.10.4 from list
*Mar  1 00:17:37.247: Temp IP addr: 20.10.10.4  for peer on Interface: FastEthernet0/0
*Mar  1 00:17:37.251: Temp  sub net mask: 255.255.255.128
*Mar  1 00:17:37.251:    DHCP Lease server: 20.10.10.1, state: 11 Purging
*Mar  1 00:17:37.255:    DHCP transaction id: 2B5
*Mar  1 00:17:37.255:    Lease: 129600 secs,  Renewal: 64800 secs,  Rebind: 113400 secs
*Mar  1 00:17:37.259:    Next timer fires after: 00:00:24
*Mar  1 00:17:37.263:    Retry count: 0   Client-ID: cisco-c400.04b8.0000-Fa0/0
*Mar  1 00:17:37.263:    Client-ID hex dump: 636973636F2D633430302E303462382E
*Mar  1 00:17:37.275:                        303030302D4661302F30
*Mar  1 00:17:37.283:    Hostname: Router
*Mar  1 00:17:37.287: DHCP: new entry. add to queue, interface FastEthernet0/0
*Mar  1 00:17:37.291: DHCP: SDiscover attempt # 1 for entry:
*Mar  1 00:17:37.291: Temp IP addr: 0.0.0.0  for peer on Interface: FastEthernet0/0
*Mar  1 00:17:37.295: Temp  sub net mask: 0.0.0.0
*Mar  1 00:17:37.295:    DHCP Lease server: 0.0.0.0, state: 3 Selecting
*Mar  1 00:17:37.299:    DHCP transaction id: 20C2
*Mar  1 00:17:37.303:    Lease: 0 secs,  Renewal: 0 secs,  Rebind: 0 secs
*Mar  1 00:17:37.303:    Next timer fires after: 00:00:04
*Mar  1 00:17:37.307:    Retry count: 1   Client-ID: cisco-c400.04b8.0000-Fa0/0
*Mar  1 00:17:37.307:    Client-ID hex dump: 636973636F2D633430302E303462382E
*Mar  1 00:17:37.319:                        303030302D4661302F30
*Mar  1 00:17:37.327:    Hostname: batman-router
*Mar  1 00:17:37.331: DHCP: SDiscover: sending 302 byte length DHCP packet
*Mar  1 00:17:37.331: DHCP: SDiscover 302 bytes
*Mar  1 00:17:37.335:             B'cast on FastEthernet0/0 interface from 0.0.0.0
*Mar  1 00:17:39.163: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:17:39.767: DHCP: Received a BOOTREP pkt
*Mar  1 00:17:39.771: DHCP: Scan: Message type: DHCP Offer
*Mar  1 00:17:39.775: DHCP: Scan: Server ID Option: 20.10.10.1 = 140A0A01

*Mar  1 00:17:39.775: DHCP: Scan: Lease Time: 129600
*Mar  1 00:17:39.779: DHCP: Scan: Renewal time: 64800
*Mar  1 00:17:39.779: DHCP: Scan: Rebind time: 113400
*Mar  1 00:17:39.783: DHCP: Scan: Subnet Address Option: 255.255.255.128
*Mar  1 00:17:39.783: DHCP: Scan: Router Option: 20.10.10.1
*Mar  1 00:17:39.787: DHCP: Scan: Domain Name: dhcp.com.pk
*Mar  1 00:17:39.787: DHCP: rcvd pkt source: 20.10.10.1,  destination:  255.255.255.255

*Mar  1 00:17:39.791:    UDP  sport: 43,  dport: 44,  length: 308
*Mar  1 00:17:39.795:    DHCP op: 2, htype: 1, hlen: 6, hops: 0
*Mar  1 00:17:39.795:    DHCP server identifier: 20.10.10.1
*Mar  1 00:17:39.799:         xid: 20C2, secs: 0, flags: 8000
*Mar  1 00:17:39.799:         client: 0.0.0.0, your: 20.10.10.5
*Mar  1 00:17:39.803:         srvr:   0.0.0.0, gw: 0.0.0.0
*Mar  1 00:17:39.803:         options block length: 60

*Mar  1 00:17:39.807: DHCP Offer Message   Offered Address: 20.10.10.5
*Mar  1 00:17:39.811: DHCP: Lease Seconds: 129600    Renewal secs:  64800    Rebind secs:   1                                                                          13400
*Mar  1 00:17:39.815: DHCP: Server ID Option: 20.10.10.1
*Mar  1 00:17:39.815: DHCP: offer received from 20.10.10.1

*Mar  1 00:17:39.819: DHCP: SRequest attempt # 1 for entry:
*Mar  1 00:17:39.819: Temp IP addr: 20.10.10.5  for peer on Interface: FastEthernet0/0
*Mar  1 00:17:39.823: Temp  sub net mask: 255.255.255.128
*Mar  1 00:17:39.823:    DHCP Lease server: 20.10.10.1, state: 4 Requesting
*Mar  1 00:17:39.823:    DHCP transaction id: 20C2
*Mar  1 00:17:39.823:    Lease: 129600 secs,  Renewal: 0 secs,  Rebind: 0 secs
*Mar  1 00:17:39.823:    Next timer fires after: 00:00:03
*Mar  1 00:17:39.823:    Retry count: 1   Client-ID: cisco-c400.04b8.0000-Fa0/0
*Mar  1 00:17:39.823:    Client-ID hex dump: 636973636F2D633430302E303462382E
*Mar  1 00:17:39.823:                        303030302D4661302F30
*Mar  1 00:17:39.823:    Hostname: batman-router
*Mar  1 00:17:39.823: DHCP: SRequest- Server ID option: 20.10.10.1
*Mar  1 00:17:39.823: DHCP: SRequest- Requested IP addr option: 20.10.10.5

*Mar  1 00:17:39.823: DHCP: SRequest placed lease len option: 129600
*Mar  1 00:17:39.823: DHCP: SRequest: 320 bytes
*Mar  1 00:17:39.823: DHCP: SRequest: 320 bytes
*Mar  1 00:17:39.827:             B'cast on FastEthernet0/0 interface from 0.0.0.0
*Mar  1 00:17:39.911: DHCP: Received a BOOTREP pkt
*Mar  1 00:17:39.911: DHCP: Scan: Message type: DHCP Ack
*Mar  1 00:17:39.915: DHCP: Scan: Server ID Option: 20.10.10.1 = 140A0A01
*Mar  1 00:17:39.915: DHCP: Scan: Lease Time: 129600
*Mar  1 00:17:39.919: DHCP: Scan: Renewal time: 64800
*Mar  1 00:17:39.919: DHCP: Scan: Rebind time: 113400
*Mar  1 00:17:39.923: DHCP: Scan: Subnet Address Option: 255.255.255.128
*Mar  1 00:17:39.923: DHCP: Scan: Router Option: 20.10.10.1
*Mar  1 00:17:39.927: DHCP: Scan: Domain Name: dhcp.com.pk
*Mar  1 00:17:39.931: DHCP: rcvd pkt source: 20.10.10.1,  destination:  255.255.255.255

*Mar  1 00:17:39.931:    UDP  sport: 43,  dport: 44,  length: 308
*Mar  1 00:17:39.935:    DHCP op: 2, htype: 1, hlen: 6, hops: 0
*Mar  1 00:17:39.935:    DHCP server identifier: 20.10.10.1
*Mar  1 00:17:39.939:         xid: 20C2, secs: 0, flags: 8000
*Mar  1 00:17:39.939:         client: 0.0.0.0, your: 20.10.10.5
*Mar  1 00:17:39.943:         srvr:   0.0.0.0, gw: 0.0.0.0
*Mar  1 00:17:39.947:         options block length: 60

*Mar  1 00:17:39.947: DHCP Ack Message
*Mar  1 00:17:39.951: DHCP: Lease Seconds: 129600    Renewal secs:  64800    Rebind secs:   1                                                                          13400
*Mar  1 00:17:39.951: DHCP: Server ID Option: 20.10.10.1
*Mar  1 00:17:40.163: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, change                                                                          d state to up
*Mar  1 00:17:42.987: DHCP: Releasing ipl options:
*Mar  1 00:17:42.987: DHCP: Applying DHCP options:
*Mar  1 00:17:42.991:   Setting default_gateway to 20.10.10.1
*Mar  1 00:17:42.991:   Adding default route 20.10.10.1

*Mar  1 00:17:43.995:   Setting default domain to dhcp.com.pk
*Mar  1 00:17:43.995: DHCP Client Pooling: ***Allocated IP address: 20.10.10.5
*Mar  1 00:17:44.071: Allocated IP address = 20.10.10.5  255.255.255.128

*Mar  1 00:17:44.075: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address        20.10.10.5, mask 255.255.255.128, hostname batman-router