Dynamic Host Configuration Protocol(DHCP)
Dynamic Host Configuration Protocol(DHCP)
Imagine we have a network of connected devices and a DHCP server that manages the IP
addresses.
Step 1: DHCP Discover - When you connect a new device, it still does not have an IP
address. It will search for an IP address. It will call over the network for a DHCP server. This
request will arrive to all of the devices, and the server will also get it.
Step 2 DHCP Offer - The DHCP hears the call, and answers with an IP address, which it
offers to the newly connected device.
Step 3 DHCP Request - The IP address arrives at the device. The device will accept it and
will send a request to use it.
Step 4 DHCP Pack - The server gets the accepting message from the device. It will provide
the IP address to the device, together with the subnet mask and the DNS server. It will write
a record with the information of the newly connected device that usually includes the MAC
address of the connected device, the IP address that was assigned, and the expiration date of
that IP address. The DHCP leases the IP address for a limited time only. After the time passes,
the IP address will go back to the IP pool of available IP addresses and can be assigned to a
new device again.
DHCP Configuration Parameters and Settings Explained
A DHCP server configuration includes many parameters and settings. This tutorial explains the
parameters and settings you need to configure a DHCP server on Cisco switches and routers.
To configure a Cisco router or switch as a DHCP server, you have to create and configure a DHCP
pool on it. A DHCP pool is a collection of IP configurations you want to assign to DHCP clients.
Each IP configuration contains a unique IP address and network settings and addresses such as
the default gateway IP, DNS servers' IP addresses, and TFTP server's IP addresses.
IP range (subnet or scope): This is a range of IP addresses that we want to assign to clients.
In each range, the first address and the last address have special meanings. The first address is
known as the network ID (or address). The last address is known as the local broadcast ID (or
address).
DHCP clients use the network address and broadcast address to request an IP configuration from
DHCP servers, while the DHCP servers use the same addresses to offer the IP configuration to
the DHCP clients. To learn how this process work in detail, please check the second part of this
tutorial.
To define a range, we use the network ID and the subnet mask. For example, to define a range
of IP addresses from 192.168.1.0 to 192.168.1.255, we would set the network ID to
192.168.1.0 and the subnet mask to 255.255.255.0.
The network ID 192.168.1.0 and the subnet mask 255.255.255.0 represent a range of IP
addresses from 192.168.1.0 to 192.168.1.255. In this range, the network address is 192.168.1.0
and the local broadcast address is 192.168.1.255.
DHCP servers do not lease the network ID and broadcast ID. Except the network ID and broadcast
ID, all addresses of the defined IP range can be leased to clients.
Reserved/excluded addresses: If you don't want to assign a few addresses from the range,
you can configure them as excluded addresses. DHCP servers do not assign the excluded
addresses. This feature allows us to configure static IP addresses on critical network resources
such as servers, printers, and routers.
The default gateway IP address: If a local host wants to send a data packet to a host that
is not available in the local network, it sends the data packet to the default gateway. This
option allows us to set a default gateway IP address for hosts. Typically, this is the IP address
of the router's interface that is directly connected to the local network.
DNS server IP addresses: DNS servers allow hosts to access network resources by using
their names instead of their IP addresses. If a DNS server is configured, you can set its IP
address in this option. If you have more than one DNS server, you can configure all of them on
hosts through this option.
TFTP server IP address: A TFTP server allows hosts to download or store files. If a TFTP
server is available in the network, you can use this option to provide the IP address of the TFTP
server to all hosts.
Lease duration: The lease duration defines the validity of the IP configuration. A DHCP client
can use the assigned IP configuration until its validity expires. Once the validity period is expired,
the client needs to obtain a new IP configuration from the server. By default, an IP configuration
remains valid for 24 hours. Depending on your requirement, you can increase or decrease it.
DHCP Address Allocation Methods:
To provide an IP configuration, a DHCP server can use three mechanisms. These mechanisms
are the following.
Static Allocation: In this method, the administrator configures an allocation table on the
DHCP server. In this table, the administrator adds the MAC addresses of all clients and assigns
an IP configuration to each client.
The DHCP server uses this table to provide IP configurations. When a client requests an IP
configuration, the DHCP server finds the client's MAC address in the table. If it finds an entry
for the client, it provides the IP configuration to the client.
But in Network 1 & 2 Hosts cannot get DHCP IP address as per your configuration. At
this time show a message DHCP Failed and API IP assigned.
To Overcome this problem, we need to configure in our network router IP DCHP
helper command show the below
Step – 3: Configure Router Helper-Address
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip helper-address 192.168.10.100
Router(config-if)#exit
Router(config)#interface Ethernet 0/0/0
Router(config-if)#ip helper-address 192.168.10.100
Router(config-if)#exit
Router(config)#exit
Router#wr
Now check from other network Host
DHCP Relay Agents:
DHCP clients use local broadcast messages to obtain IP addresses from the DHCP server. By
default, routers do not forward local broadcast messages. This means, if the DHCP server is
configured on another network or a router is configured between the DHCP server and DHCP
clients, the DHCP clients will not receive IP addresses from the DHCP server.
In such a situation, a network administrator has two choices either configure a DHCP server in
each subnet or configure the router as a DHCP relay agent that connect the subnet to the DHCP
server. A DHCP relay agent sits between a DHCP server and DHCP clients and allows the DHCP
clients to obtain IP addresses from the DHCP server that is not configured on the same LAN.
In this session, we will understand how configure Cisco routers as DHCP relay agents trough a
packet tracer example.
LAB Configuration Topology – 3:
Task – 3:
Router – 1 Configuration
Router>enable
Router#configure terminal
Router(config)#interface GigabitEthernet 0/1
Router(config-if)#ip add 192.168.10.1 255.255.255.0
Router(config-if)#no shutdown
Router(config)#int g0/1
Router(config-if)#ip helper-address 200.100.10.1
Router(config-if)#exit
Router(config)#ip route 0.0.0.0 0.0.0.0 200.100.10.1
Router(config)#exit
Router#wr
Router – 2 Configuration
Router>enable
Router#configure terminal
Router(config)#ip route 0.0.0.0 0.0.0.0 200.100.10.2
Router(config)#exit
Router#wr
Task – 4:
Now, go to Host PC (1, 2, 3 and 4), Command Prompt > write the following command
C:\>ipconfig /renew
DHCP configuration on Cisco switches
In a small network, a Cisco switch and a generic wireless access point are used to provide
connectivity between hosts. Wired hosts are directly connected to the switch. Wireless hosts are
connected to the access point and the access point is connected to the switch. The following
image shows this network.
Configure the switch to act as the DHCP server:
Switch>enable
Switch#configure terminal
Switch(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10
Switch(config)#ip dhcp pool VLAN-N-1
Switch(dhcp-config)#network 192.168.1.0 255.255.255.0
Switch(dhcp-config)#default-router 192.168.1.1
Switch(dhcp-config)#dns-server 8.8.8.8
Switch(dhcp-config)#exit
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.1.5 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#exit
Switch#wr
Configuring DHCP clients
To configure a host as a DHCP client, change the host's IP configuration option to DHCP. For this,
click the device and click the Desktop option and click the IP configuration and select the DHCP
option.
You can also use the 'ipconfig' command to view the IP address. To use the 'ipconfig'
command, select the command prompt of the device and run this command.
Configure DHCP Server for multiple VLANs on the Switch
Which rule does the DHCP server use when there is an IP address conflict?
a. The address is removed from the pool until the conflict is resolved.
b. The address remains in the pool until the conflict is resolved.
c. Only the IP detected by Gratuitous ARP is removed from the pool.
d. Only the IP detected by Ping is removed from the pool.
e. The IP will be shown, even after the conflict is resolved.
The network administrator can see the DHCP discovery packet in R1, but R2 is not replying to the
DHCP request. The R1 related interface is configured with the DHCP helper address. If the PC is
directly connected to the Fa0/1 interface on R2, the DHCP server assigns as IP address from the
DHCP pool to the PC.
Which two commands resolve this issue? (Choose two.)
a. service dhcp-relay command on R1
b. ip dhcp relay information enable command on R1
c. ip dhcp option 82 command on R2
d. service dhcp command on R1
e. ip dhcp relay information trust-all command on R2
Q9. Order the DHCP process steps. (Not all options are used.)