0% found this document useful (0 votes)
5 views

Share 'Introduction to DHCP

The document provides an introduction to DHCP (Dynamic Host Configuration Protocol) and explains its functionality in dynamically assigning IP addresses to devices on a network. It includes a step-by-step guide on configuring a Cisco IOS DHCP server and client, as well as setting up DHCP exclusions and relay agents. Additionally, it covers the basics of DNS (Domain Name Service) and its role in resolving hostnames to IP addresses.

Uploaded by

Mazidul Islam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Share 'Introduction to DHCP

The document provides an introduction to DHCP (Dynamic Host Configuration Protocol) and explains its functionality in dynamically assigning IP addresses to devices on a network. It includes a step-by-step guide on configuring a Cisco IOS DHCP server and client, as well as setting up DHCP exclusions and relay agents. Additionally, it covers the basics of DNS (Domain Name Service) and its role in resolving hostnames to IP addresses.

Uploaded by

Mazidul Islam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to DHCP

IP addresses can be configured statically or dynamically. Normally we configure static IP addresses on


network devices like routers, switches, firewalls and servers while we dynamically assign IP addresses to
computers, laptops, tablets, smartphones etc. The dynamic method uses DHCP (Dynamic Host
Configuration Protocol) and in this short lesson I want to show you how it works.
Let’s take a look at the following picture:

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.

network This command is executed in DHCP configuration mode to specify a network in


A.B.C.D /x which the DHCP pool provides DHCP addresses from to host clients upon request.

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

Create a DHCP pool on R1 using the name “LAB_POOL1”


Assign the domain name “TESTLAB.LOCAL” to the DHCP pool “LAB_POOL1”
Assign the network 10.114.12.0/24 to the DHCP pool “LAB_POOL1”
Assign the DHCP Address lease time of 7 days to the DHCP pool “LAB_POOL1”
Assign the DNS Servers 10.114.18.6 and 10.114.18.7 to the DHCP pool “LAB_POOL1”
Assign the WINS Servers 10.114.18.4 and 10.114.18.5 to the DHCP pool “LAB_POOL1”
Assign the default gateway of 10.114.12.1 to the DHCP pool “LAB_POOL1”
Configure R2’s FastEthernet0/0 interface to obtain an IP Address via DHCP. Verify that R1 has provided
R2 a DHCP IP address and that you can ping R1’s FastEthernet0/0 interface using the newly acquired
DHCP address.
Objective 1. – Create a DHCP pool on R1 using the name “LAB_POOL1”
R1>enable
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip dhcp pool LAB_POOL1
Objective 2. – Assign the domain name “TESTLAB.LOCAL” to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#domain-name TESTLAB.LOACL
Objective 3. – Assign the network 10.114.12.0/24 to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#network 10.114.12.0 /24
Objective 4. – Assign the DHCP Address lease time of 7 days to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#lease 7
Objective 5. – Assign the DNS Servers 10.114.18.6 and 10.114.18.7 to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#dns-server 10.114.18.6 10.114.18.7
Objective 6. – Assign the WINS Servers 10.114.18.4 and 10.114.18.5 to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#netbios-name-server 10.114.18.4 10.114.18.5
Objective 7. – Assign the default gateway of 10.114.12.1 to the DHCP pool “LAB_POOL1”
R1(dhcp-config)#default-router 10.114.12.1
R1(dhcp-config)#end
R1#
Objective 8. – Configure R2’s FastEthernet0/0 interface to obtain an IP Address via DHCP. Verify that R1
has provided R2 a DHCP IP address and that you can ping R1’s FastEthernet0/0 interface using the newly
acquired DHCP address.

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

R2#show ip interface brief FastEthernet0/0


Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.114.12.2 YES DHCP up up
R2#ping 10.114.12.1

Type escape sequence to abort.


Sending 5, 100-byte ICMP Echos to 10.114.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/59/152 ms
R2#

Configuring DHCP Server Exclusion Range

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.

DHCP server Configuration

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

Router(config)#ip dhcp excluded-address 192.168.1.1


Router(config)#ip dhcp excluded-address 192168.1.100

Router(config)#ip dhcp pool NOA


Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.100
Router(dhcp-config)#dns-server 192.168.1.50
Router(dhcp-config)#exit
1P Helper Address Configuration
Router(config)#ip dhcp excluded-address 192.168.2.100
Router(config)#ip dhcp pool NOA_VLAN20
Router(dhcp-config)#default-router 192.168.2.100
Router(dhcp-config)#dns-server 192.168.1.50
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#exit
Switch (config)#int vlan 20
Switch (config-if)#ip helper-address 192.168.1.1
Switch (co nfig-if)#exit
Switch (config)#ip routing
Domain Name Service (DNS)
Domain Name Service (DNS) is an application layer protocol used to resolve hostnames to IP addresses.
Although a host can be accessed by using only its IP address, DNS makes your life easier by using domain
names. For example, you can access the Google website by typing http://208.117.229.214 in your
browser, but it is much easier to type http://www.google.com.
Each host that wants to use DNS needs to have a DNS server configured. When you type a URL in your
browser (e.g. http://www.google.com), your host will query the DNS server for the IP address
of www.google.com. The DNS server will resolve the query and send the answer back to the host. The
host will then be able to establish a connection to http://www.google.com.
Consider the following example:
1. The user enters www.google.com in his browser. The host needs to know the IP address
of www.google.com in order to establish a network connection. The host sends a DNS query to its DNS
server, looking for the IP address of www.google.com.
2. The DNS server sends a reply back to the host, listing the IP address
of 208.117.229.214 as www.google.com’s IP address.
3. The host can establish a network connection to the web server hosting www.google.com.

DNS uses a well-known UDP port 53.

You might also like