4.3. Configuring DHCP Client

Overview

Function Introduction

Dynamic Host Configuration Protocol(DHCP) client can acquire IP address and configuration dynamically from DHCP server by DHCP. If client and server is on the same physical subnet, client can communicate with server directly, otherwise they need DHCP relay agent which is used to forward DHCP messages. DHCP client can request IP address from DHCP server by broadcasting DHCP messages. After received IP address and lease correspond to it, client will configure itself and set the expired time. When half past the lease, client will sent DHCP messages for a new lease to use the IP address continually. If it success, DHCP client will renew the lease. DHCP client can send option request to server, which may be one or several of router, static-route, classless-static-route, classless-static-route-ms, tftp-server-address, dns-nameserver, domain-name, netbios-nameserver and vendor-specific. By default, options include router, static-route, classless-static-route, classless-static-route-ms, tftp-server-address will be requested from server. We can cancel one or several of these option requests by command.

Principle Description

N/A

Configuration

image

Fig. 4.4 DHCP Client

step 1 Enter the configure mode

Switch# configure terminal

step 2 Enter the interface configure mode

Switch(config)# interface eth-0-1
Switch(config-if)# no switchport
Switch(config-if)# no shutdown

step 3 disable static-route and enable DHCP client

Switch(config-if)# no dhcp client request static-route
Switch(config-if)# ip address dhcp

step 4 Exit the configure mode

Switch(config-if)# end

step 5 Validation

Check interface configuration:

Switch# show running-config interface eth-0-1
Building configuration...
 !

interface eth-0-1
no switchport
ip address dhcp
no dhcp client request static-route
 !

Check all DHCP client status:

Switch# show dhcp client verbose
DHCP client informations:
============================================================

eth-0-1 DHCP client information:
Current state: BOUND
Allocated IP: 4.4.4.199 255.255.255.0
Lease/renewal/rebinding: 1187/517/1037 seconds
Lease from 2023-11-18 05:59:59 to 2023-11-18 06:19:59
Will Renewal in 0 days 0 hours 8 minutes 37 seconds
DHCP server: 4.4.4.1
Transaction ID: 0x68857f54
Client ID: switch-7e39.3457.b700-eth-0-1

Show DHCP client statistics:

Switch# show dhcp client statistics
DHCP client packet statistics:
============================================================
DHCP OFFERS received: 1
DHCP ACKs received: 2
DHCP NAKs received: 0
DHCP Others received: 0
DHCP DISCOVER sent: 1
DHCP DECLINE sent: 0
DHCP RELEASE sent: 0
DHCP REQUEST sent: 2
DHCP packet send failed: 0

Application cases

N/A