DHCP
DHCP
●
Basic functions of DHCP
●
Configuring DHCP in Cisco IOS
The Purpose of DHCP
● DHCP is used to allow hosts to automatically/dynamically learn various aspects
of their network configuration, such as IP address, subnet mask, default
gateway, DNS server, etc, without manual/static configuration.
●
Typically used for ‘client devices’ such as workstations (PCs),
phones, etc.
●
Devices such as routers, servers, etc, are usually manually
configured.
●
In small networks (such as home networks) the router typically acts as the
DHCP server for hosts in the LAN.
●
In larger networks, the DHCP server is usually a
Windows/Linux server.
The Basic Functions of DHCP
The Basic Functions of DHCP
The Basic Functions of DHCP
C:\Users\
user>ipconfig /all
[output omitted]
Ethernet adapter
Ethernet0: This PC was previously assigned this IP address by the DHCP
Connection-specific DNS Suffix server, so it asked to receive the same address again this
Description . . . . . . . . . . . :time.
Intel(R) 82579LM Gigabit Network
Physical Address. . . . . . . .
Connection
. : . : 78-2B-CB-AC-
DHCP Enabled. . . . . . . . . .
08-67 . :
Yes
Autoconfiguration Enabled . . . . :
IPv4
Yes Address. . . . . . . . . . . : (Preferred
192.168.0.167 )
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Saturday, January 23, 2021
12:02:04 PM Lease Expires . . . . . . . . . . : Saturday, January
23, 2021 2:02:05 PM
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . :
192.168.0.1
DHCP Server . . . . . . . . . . . :
Enabled
192.168.0.1
DNS Servers
[output . . . . . . . . . . . :
omitted]
192.168.0.1 DHCP server ‘lease’ IP address to clients.
These leases are usually not permanent, and the client must
give up the address at the end of the lease.
ipconfig /release
C:\Users\user>ipconfig
/release
Windows IP
Configuration [output
Ethernet adapter Ethernet0:
omitted]
Connection-specific DNS Suffix
. : Default Gateway . . . . . .
. . . :
[output
omitted]
192.168.0.167 is now
free to assign to
another client. DHCP Release:
I don’t need this
address anymore.
. .16
192.168.0.0/
1 7
24
DHCP
Release
.1
DHCP servers use UDP
67. DHCP clients use UDP
68.
192.168.0.0/
24
.16
7
ipconfig /renew
C:\Users\user>ipconfig /renew
C:\Users\user>ipconfig /all
. .16
192.168.0.0/
1 7
24
DHCP
Discover DHCP Discover:
Are there any DHCP servers in this
network? I need an IP address.
.
192.168.0.0/
1
24
DHCP
Discover
.1
192.168.0.0/
24
DHCP Offer
DHCP Discover:
Are there any DHCP servers in this
network? I need an IP address.
DHCP Offer:
How about this IP
address?
.
192.168.0.0/
1
24
DHCP Offer
.1
DHCP Offer:
How about this IP
address?
DHCP Request:
I want to use the IP address
you offered me.
.
192.168.0.0/
1
24
DHCP
Request
.1
192.168.0.0/
24
DHCP Ack
DHCP Discover:
Are there any DHCP servers in this
network? I need an IP address.
DHCP Offer:
How about this IP
address?
DHCP Request:
I want to use the IP address
you offered me.
DHCP Ack:
Okay, you may use
it.
.
192.168.0.0/ .16
1 7
24
DHCP Ack
.1
R2 R1 PC1
SRV1
DHCP
Relay
Src: 192.168.1.1 Dst: Src: 0.0.0.0 Dst:
192.168.10.10 255.255.255.255 Discove
r
Src: 192.168.10.10 Dst: Src: 192.168.1.1 Dst: (unicast or
Offe 192.168.1.1 255.255.255.255)
r
Src: 192.168.1.1 Dst: Src: 0.0.0.0 Dst:
192.168.10.10 255.255.255.255 Reques
t
Src: 192.168.10.10 Dst: Src: 192.168.1.1 Dst: (unicast or
Ac 192.168.1.1 255.255.255.255)
DHCP
Relay
192.168.10.0/ 10.0.0.0/3 Agent 192.168.1.0/
24 0 24
. .2 . .1
DHCP .10 g0/1 g0/ g0/1 g0/1 .100
Serve 1 0 0
r
R2 R1 PC1
SRV1
DHCP Server Configuration in IOS
R1(config)#ip dhcp excluded-address 192.168.1.1 Specify a range of addresses that
192.168.1.10 won’t
R1(config)#ip dhcp pool be given to DHCP clients.
LAB_POOL Create a DHCP pool.
R1(dhcp-config)#network 192.168.1.0 ?
/nn or A.B.C.D Network mask or prefix
length Specify the subnet of addresses to be
<cr> assigned to clients (except the excluded
addresses)
R1(dhcp-config)#network 192.168.1.0 /24
R1(dhcp-config)#dns-server Specify the DNS server that DHCP
8.8.8.8 clients should use.
R1(dhcp-config)#domain-name ensab.com
192.168.1.0/
.1
R1 24
.1
g0/ PC1
1 1
DHCP Server Configuration in IOS
R1#show ip dhcp binding
Bindings from all pools not associated with
IP
VRF: Client-ID/ Lease Typ
address Hardware expiration e
address/ User
192.168.1.11 name Jan 24 2021 10:52 Automati
0100.0c29.e727.39 AM c
C:\Users\
user>ipconfig /all
Ethernet adapter
Connection-specific DNS Suffix
Ethernet0: . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network
ensab.com
Connection #2 Physical Address. . . . . . . . . : 00-0C-29-E7-27-39
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . :
Yes IPv4 . . . . . . . . . : 192.168.1.11(Preferre
Address. . d)
Subnet . . . . . . . . . : 255.255.255.0
Mask . .
Lease . . . . . . . . . : Saturday, January 24, 2021
Obtained. 2:22:35 PM
Lease . . . . . . . . . : Saturday, January 24, 2021
Expires
NetBIOS . Tcpip. . . . . . . .7:52:35
over : PM
Default . . . . . . . . . : 192.168.1.
Enabled
Gateway 1
DHCP . . . 192.168.1.0/
. . . . . . : 192.168.1.
Server .1
R1 . . 24 1
.1
DNS . . . . . . . . . : 8.8.8.8
Servers . . g0/ PC1
1 1
DHCP Relay Agent Configuration in IOS
Configure the interface connected to the
R1(config)#interface
subnet of the client devices.
g0/1
R1(config-if)#ip helper-address
192.168.10.10 Configure the IP address of the DHCP
R1(config-if)#do show ip interface g0/1 server as the ‘helper’ address.
GigabitEthernet0/1 is up, line protocol
is up
Internet address is 192.168.1.1/24
Broadcast address is 255.255.255.255
MTU is 1500
Address determined by non-volatile
memory
Helper
bytes address is
192.168.10.10
[output
omitted]
DHCP
Relay
192.168.10.0/ 10.0.0.0/3 Agent 192.168.1.0/
24 0 24
. .2 . .1
DHCP .10 g0/1 g0/ g0/1 g0/1 .10
Serve 1 0 0 0
r
R2 R1 PC1
SRV1
DHCP Client Configuration in IOS
R2(config)#interface
g0/1
R2(config-if)#ip address
dhcp Use the ip address dhcp mode to tell
R2(config-if)#do sh ip interface g0/1 the router to use DHCP to learn its IP
GigabitEthernet0/1 is up, line protocol
isInternet
up address is address.
192.168.10.1/24 Broadcast address
is 255.255.255.255 Address
determined by DHCP
[output
omitted]
DHCP DHCP
Clien Relay
192.168.10.0/ t 10.0.0.0/3 Agent 192.168.1.0/
24 0 24
.1 . . .1
DHCP .10 g0/1 2
g0/ g0/1 g0/1 .100
Serve 0 0
r
R2 R1 PC1
SRV1
Command Summary
C:\Users\user> ipconfig /release
C:\Users\user> ipconfig /renew
●
Basic functions of DHCP
●
Configuring DHCP in Cisco IOS
Supplementary Materials