4.5. Configuring DHCP server
Overview
Function Introduction
A DHCP server is an Internet host that returns configuration parameters to DHCP clients .DHCP server can provide IP address and network configuration for DHCP client by DHCP. For provide DHCP service DHCP server need to be configured first. For example, IP address pool need be create , default gateway should be set in a pool, and some network parameters for DHCP client should be set before DHCP working. After DHCP server start to work, it will find a valid IP address from pool for DHCP client when receiving client’s request. Meantime it also send network configuration parameters to client. The IP address assigned by DHCP server have a period of validity(lease), so DHCP client need to renew its lease before the lease expired for reserving current IP address by sending DHCP REQUEST message.
If DHCP server was in the same subnet with client,it can normal work after connect to subnet. Otherwise DHCP relay was needed for server providing DHCP service, which can help to forward DHCP message between server and client.
Main options supported by DHCP server include bootfile-name, dns-server, domain-name, gateway, netbios-name-server, netbios-node-type, tftp-server-address. Besides these, some raw options were also be supported ,which were set with option code.
Principle Description
N/A
Configuration
Configuring DHCP server
step 1 Enter the configure mode
Switch# configure terminal
step 2 Enable DHCP server globally configure the ip address pool
Configure on Switch1:
Switch(config)# service dhcp enable
Switch(config)# dhcp server
Switch(config)# dhcp pool pool5
Switch(dhcp-config)# network 5.5.5.0/24
Switch(dhcp-config)# gateway 5.5.5.1
Switch(dhcp-config)# exit
step 3 Enter the interface configure mode set the attributes and ip address
Configure on Switch1:
Switch(config)# interface eth-0-9
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address 5.5.5.1/24
Switch(config-if)# dhcp server enable
Switch(config-if)# exit
Configure on Switch2:
Switch# configure terminal
Switch(config)# interface eth-0-9
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address dhcp
Switch(config-if)# exit
step 4 Validation
Check DHCP Server(Switch1) configuration
Switch# show running-config
!
service dhcp enable
!
interface eth-0-9
no switchport
dhcp server enable
ip address 5.5.5.1/24!
!
dhcp server
dhcp pool pool5
network 5.5.5.0/24
gateway 5.5.5.1
Check DHCP client status on DHCP Client(Switch2):
Switch# show dhcp client verbose
DHCP client informations:
===========================================================
eth-0-9 DHCP client information:
Current state: BOUND
Allocated IP: 5.5.5.2 255.255.255.0
Lease/renewal/rebinding: 1194/546/1044 seconds
Lease from 2023-02-04 07:40:12 to 2023-02-04 08:00:12
Will Renewal in 0 days 0 hours 9 minutes 6 seconds
DHCP server: 5.5.5.1
Transaction ID: 0x45b0b27b
Default router: 5.5.5.1
Classless static route:
Destination: 5.5.4.0, mask: 255.255.255.0, Nexthop: 5.5.5.1
TFTP server addresses: 5.5.5.3
Client ID: switch-6e6e.361f.8400-eth-0-9
Check DHCP server statistics on DHCP Server(Switch1):
Switch# show dhcp server statistics
DHCP server packet statistics:
============================================================
Message Received:
BOOTREQUEST: 0
DHCPDISCOVER: 1
DHCPREQUEST: 1
DHCPDECLINE: 0
DHCPRELEASE: 0
DHCPINFORM: 0
Message Sent:
BOOTREPLY: 0
DHCPOFFER: 1
DHCPACK: 1
DHCPNAK: 0
Check DHCP server addresses and interfaces on DHCP Server(Switch1):
Switch# show dhcp server binding all
IP address Client-ID/ Lease expiration Type
Hardware address
5.5.5.2 6e:6e:36:1f:84:00 Sat 2023.02.04 08:00:12 Dynamic
Switch# show dhcp server interfaces
List of DHCP server enabled interface(s):
DHCP server service status: enabled
Interface Name
============================================================
eth-0-9
Configuring DHCP server with relay
step 1 Enter the configure mode
Switch# configure terminal
step 2 Enable DHCP server globally configure the ip address pool and DHCP relay
Configure on Switch1
Switch(config)# service dhcp enable
Switch(config)# dhcp server
Switch(dhcp-config)# dhcp pool pool4
Switch(dhcp-config)# network 4.4.4.0/24
Switch(dhcp-config)# gateway 4.4.4.1
Switch(dhcp-config)# exit
Configure on Switch2
Switch(config)# service dhcp enable
Switch(config)# dhcp relay
Switch(config)# dhcp-server 1 5.5.5.1
step 2 Add a ip route
Configure on Switch1
Switch(config)# ip route 4.4.4.0/24 5.5.5.2
step 4 Enter the interface configure mode set the attributes and ip address
Configure on Switch1:
Switch(config)# interface eth-0-9
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address 5.5.5.1/24
Switch(config-if)# dhcp server enable
Switch(config-if)# exit
Configure on Switch2:
Switch(config)# interface eth-0-17
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address 4.4.4.1/24
Switch(config-if)# dhcp-server 1
Switch(config-if)# interface eth-0-9
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address 5.5.5.2/24
Switch(config-if)# exit
Configure on Switch3:
Switch(config)# interface eth-0-17
Switch(config-if)# no switchport
Switch(config-if)# no shutdown
Switch(config-if)# ip address dhcp
Switch(config-if)# exit
step 5 Exit the configure mode
Switch(config)# end
step 6 Validation
Check DHCP Server(Switch1) configuration:
Switch# show running-config
!
service dhcp enable
!
interface eth-0-9
no switchport
dhcp server enable
ip address 5.5.5.1/24!
!
ip route 4.4.4.0/24 5.5.5.2
!
dhcp server
dhcp pool pool4
network 4.4.4.0/24
gateway 4.4.4.1
Check DHCP client status on DHCP Server(Switch1):
Switch# show dhcp client verbose
DHCP client informations:
============================================================
eth-0-17 DHCP client information:
Current state: BOUND
Allocated IP: 4.4.4.5 255.255.255.0
Lease/renewal/rebinding: 1199/517/1049 seconds
Lease from 2023-02-06 05:23:09 to 2023-02-06 05:43:09
Will Renewal in 0 days 0 hours 8 minutes 37 seconds
DHCP server: 5.5.5.1
Transaction ID: 0x192a4f7d
Default router: 4.4.4.1
Classless static route:
Destination: 5.5.4.0, mask: 255.255.255.0, Nexthop: 4.4.4.1
TFTP server addresses: 5.5.5.3
Client ID: switch-3c9a.b29a.ba00-eth-0-17
Check DHCP server statistics on DHCP Server(Switch1):
Switch# show dhcp server statistics
DHCP server packet statistics:
============================================================
Message Received:
BOOTREQUEST: 0
DHCPDISCOVER: 1
DHCPREQUEST: 1
DHCPDECLINE: 0
DHCPRELEASE: 0
DHCPINFORM: 0
Message Sent:
BOOTREPLY: 0
DHCPOFFER: 1
DHCPACK: 1
DHCPNAK: 0
Check DHCP server addresses and interfaces on DHCP Server(Switch1):
Switch# show dhcp server binding all
IP address Client-ID/ Lease expiration Type
Hardware address
4.4.4.5 3c:9a:b2:9a:ba:00 Mon 2023.02.06 05:43:09 Dynamic
Switch# show dhcp server interfaces
List of DHCP server enabled interface(s):
DHCP server service status: enabled
Interface Name
============================================================
eth-0-9
Application cases
N/A