Share 'Introduction to DHCP
Share 'Introduction to DHCP
On the left side we have a computer without IP address. On the right side there’s a DHCP server
configured with static IP address 192.168.1.254. This DHCP server will supply an IP address to our
computer, this is how it works:
The computer will send a DHCP discover message. This is a broadcast because it doesn’t have an IP
address and it doesn’t know if there is a DHCP server on the network. Of course in our scenario we do
have a DHCP server so it will respond to this broadcast as following:
The DHCP server will respond with a DHCP offer message which contains an IP address for the computer
(we have to configure the DHCP server to define which IP addresses we want to give). If we want we can
also assign a default gateway and DNS server(s) to the computer. The computer will respond to this
information:
The computer will send a DHCP Request in response to the DHCP offer message, asking nicely if it’s OK
to use the information that it has received. Our DHCP server will respond to this as following:
The DHCP server will respond with a DHCP ACK message to tell the computer it’s OK to use this
information. Now you have an idea what DHCP is like
Configuring Cisco IOS DHCP Server
In this lab you will configure R1 as a DHCP server and R2 as a DHCP client to simulate a PC on the
network.
Familiarize yourself with the following new command(s) listed below;
Command Description
ip dhcp pool This command is executed in global configuration mode to create a new Cisco IOS
POOL_NAME DHCP Server pool.
domain- This command is executed in DHCP configuration mode to specify a domain name
name NAME to be included in DHCP replies.
lease days
hours This command is executed in DHCP configuration mode to specify the DHCP
minutes address lease time of IP addresses allocated by that DHCP Server. The default is
seconds 24 hours.
dns-server
10.114.12.16 This command is executed in DHCP configuration mode to specify DNS Server(s)
10.114.54.16 to be included in DHCP replies.
netbios-
name-server This command is executed in DHCP configuration mode to specify WINS Server(s)
A.B.C.D to be included in DHCP replies.
default-
router This command is executed in DHCP configuration mode to specify the default
A.B.C.D gateway that will be included in DHCP replies.
The following logical topology shown below is used in this lab;
R-1
interface FastEthernet0/0
description ### LAN INTERFACE ###
ip address 10.114.12.1 255.255.255.0
no shut
R-2
interface FastEthernet0/0
description ### LAN INTERFACE ###
no shut
To verify that FastEthernet0/0 has learned its IP address via DHCP use the show ip interface brief
command.
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface Fastethernet0/0
R2(config-if)#ip address dhcp
R2(config-if)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
%DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 10.114.12.2, mask
255.255.255.0, hostname R2
bjective 1. – Create a IP DHCP Exclusion range to exclude the first and last 25 IP addresses of the
10.115.10.0/24 network on R1.
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip dhcp excluded-address 10.115.10.1 10.115.10.25
R1(config)#ip dhcp excluded-address 10.115.10.229 10.115.10.254
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#
Objective 2. – Verify your configuration by renewing the IP address on R2’s FastEthernet0/0 interface.
To clear the DHCP IP address from an Ethernet interface you can bounce the interface by shutting it
down and waiting 10 seconds and bringing it back up or you can configure the interface to have no ip
address then wait 10 seconds and configure the interface to have a DHCP IP Address again thus forcing
the router to send a dhcp request.
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface FastEthernet0/0
R2(config-if)#no ip address
R2(config-if)#ip address dhcp
R2(config-if)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#
%DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP
address 10.115.10.26, mask 255.255.255.0, hostname R2
R2#
DHCP Relay Agent –
DHCP relay agent is any TCP/IP host which is used to forward request and replies between DHCP server
and client when the server is present on the different network. Relay agents receive DHCP messages and
then generate a new DHCP message to send out on another INTERFACE. Also, DHCP relay agent adds a
giaddr (gateway address of packet) field and also the Relay agent information option 82 if enabled. The
option field is removed when the server reply is forwarded to the host.
Note – The discover and request messages are unicast by the DHCP relay agent.
RTR-0
interface FastEthernet0/0
ip address 192.168.10.1 255.255.255.0
duplex auto
speed auto
!
ip dhcp excluded-address 192.168.20.1
ip dhcp excluded-address 192.168.20.5
!
ip dhcp pool LAB
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 8.8.8.8
ip dhcp pool LAB-20
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
dns-server 4.4.4.4
!
ip route 192.168.20.0 255.255.255.0 192.168.10.2
RTR-1
interface FastEthernet0/0
ip address 192.168.10.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.20.1 255.255.255.0
ip helper-address 192.168.10.1
duplex auto
speed auto
!
The broadcast DHCP Acknowledgement message is recieved by the DHCP client as the switch broadcast
the message through all its ports.
Router(config)#no ip routing
Router(config)#ip default-gateway 192.168.1.100
Router(config)#int f0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit