DHCP Server
DHCP (Dynamic Host Configuration Protocol) is a network protocol used to automatically assign IP addresses and other network settings to devices in a network. It helps computers, phones, and other devices connect to a network without manually configuring the IP address.
1. Definition of DHCP?
- DHCP is a client-server protocol that automatically provides an IP address, subnet mask, default gateway, and DNS server to devices when they join a network.
- For example, when you connect your laptop to a Wi-Fi router at home, the router’s DHCP service automatically gives your laptop an IP address so it can access the internet.
2. Purpose of DHCP?
The main purpose of DHCP is to simplify network management. Without DHCP, a network administrator would have to manually assign an IP address to every device in the network. DHCP automates this process and reduces configuration errors.
3. How DHCP Works (DORA Process)
DHCP works using a four-step process commonly called DORA:
- Discover – The device (DHCP client) broadcasts a request to find a DHCP server in the network.
- Offer – The DHCP server responds with an available IP address offer.
- Request – The client requests the offered IP address from the server.
- Acknowledge – The server confirms and assigns the IP address to the client.
This process allows the device to obtain network configuration automatically.
4. DHCP Ports
DHCP uses UDP ports for communication:
- UDP Port 67 – Used by the DHCP server.
- UDP Port 68 – Used by the DHCP client.
Components of the DHCP Protocol
The DHCP architecture consists of the DHCP Server, Client, Relay, IP Address Pool, Subnet, Lease, DNS Servers, and Default Gateway. Each component has its unique role, which you can read in the table below:
| Component | Function |
|---|---|
| DHCP Server | Automatically assigns IP addresses from a pool of available addresses and provides additional network configuration parameters to connected devices. |
| DHCP Client | Devices that request for IP address and other network configuration information from a DHCP server. This includes computers, laptops, and mobile devices. |
| DHCP Relay | Facilitates communication between DHCP clients and servers, especially in networks with multiple subnets. |
| IP Address Pool | Holds a collection of available IP addresses that can be assigned to a DHCP client. |
| Subnet | A smaller segment of an IP network is designed to streamline network management. |
| Lease | The duration for which the assigned IP address and configuration details remain valid. |
| DNS Servers | DHCP servers can also relay DNS server information to clients for resolving domain names to IP addresses. |
| Default Gateway | The edge network device where packets are sent if the destination is outside the local network. |
Purpose of DHCP in Details?
DHCP (Dynamic Host Configuration Protocol) is used to automatically assign IP addresses and network settings to devices in a network. It helps devices communicate without manual configuration.
- Automatic IP Address Assignment
The main purpose of DHCP is to automatically provide an IP address to every device connected to the network. When a computer, mobile phone, or printer joins the network, DHCP gives it an available IP address automatically.
- Reduce Manual Work
Without DHCP, network administrators must manually configure IP address, subnet mask, gateway, and DNS settings on every device. DHCP removes this manual work and saves time.
- Prevent IP Conflicts
DHCP helps prevent IP conflicts. If two devices use the same IP address, communication problems occur. DHCP assigns unique IP addresses to each device to avoid this issue.
- Centralized Network Management
DHCP allows administrators to manage network settings from one central server. Changes to gateway, DNS, or IP range can be controlled easily without configuring every device separately.
- Faster Network Connectivity
DHCP makes network connection faster. When a new device connects to Wi-Fi or LAN, it automatically receives all required network settings and becomes ready to use within seconds.
- Efficient Use of IP Addresses
DHCP uses a lease system to assign IP addresses temporarily. When a device disconnects from the network, the IP address becomes available for another device. This helps use IP addresses efficiently.
- Useful for Large Networks
In large office or enterprise networks, manually configuring thousands of devices is difficult. DHCP simplifies network administration and reduces configuration errors.
Summary
The purpose of DHCP is to simplify network configuration by automatically assigning IP addresses and other network settings. It reduces manual work, prevents IP conflicts, speeds up connectivity, and makes network management easier.
School or College Example?
- In a computer lab with 100 computers, manually configuring IP addresses on every system would take a long time. DHCP automatically assigns network settings to all computers when they start.
- This makes network management easier for administrators.
Enterprise Network Example?
- In a large company, employees connect laptops, IP phones, printers, and mobile devices every day. DHCP automatically provides network settings to thousands of devices without manual configuration.
- This saves time and reduces network errors.
ip dhcp pool Left_Network Create the DHCP pool Left_Network and enter pool configuration mode.
default-router 192.168.1.1 Define the gateway IP address.
dns-server 192.168.1.2 the DNS server IP address.
network 192.168.1.0 255.255.255.0 Define the IP range for this pool.
exit
DHCP DORA Process
DHCP DORA Process is the 4-step process used by Dynamic Host Configuration Protocol (DHCP) to automatically assign an IP address and other network settings to a device in a network.
DORA stands for Discover, Offer, Request, Acknowledge.
1. Discover (DHCP Discover)
When a device (computer, phone, laptop) connects to a network, it does not have an IP address.
So the device sends a DHCP Discover broadcast message to find a DHCP server in the network.
- The message is broadcast to all devices in the network.
- Source IP: 0.0.0.0
- Destination IP: 255.255.255.255
- Purpose: To locate a DHCP server.
Example:
A laptop connects to a Wi-Fi router and sends a discover message asking “Is there any DHCP server available?”
2. Offer (DHCP Offer)
When the DHCP server receives the discover message, it replies with a DHCP Offer message.
- The server offers an available IP address from its IP pool.
- It also includes network configuration information such as:
IP Address
Subnet Mask
Default Gateway
DNS Server
Example:
The router replies:
“Here is an available IP address 192.168.1.20 for you.”
3. Request (DHCP Request)
After receiving the offer, the client sends a DHCP Request message to the server.
- The client requests the offered IP address.
- This message is also broadcast so other DHCP servers know which offer was accepted.
Example:
The laptop sends a request saying:
“I want to use the IP address 192.168.1.20 offered by this DHCP server.”
4. Acknowledge (DHCP Acknowledge)
Finally, the DHCP server sends a DHCP Acknowledge (ACK) message.
- The server confirms the IP assignment.
- The client can now use the IP address.
- The server also sets a lease time (how long the IP address can be used).
Example:
The router replies:
“IP address 192.168.1.20 is assigned to you for 24 hours.”
Simple Flow Example
Laptop connects to network →
- Discover – Laptop searches for DHCP server
- Offer – Router offers IP address
- Request – Laptop requests that IP
- Acknowledge – Router confirms and assigns the IP
OR
DORA Process in DHCP?
DORA is the process used by DHCP to automatically assign an IP address to a device in a network. The word DORA stands for Discover, Offer, Request, and Acknowledge. These are the four communication steps between the client device and the DHCP server.
Discover:
- When a device such as a laptop or mobile phone connects to a network for the first time, it does not have an IP address. The device sends a broadcast message to the network asking if any DHCP server is available. This message is called DHCP Discover.
- The client sends this message to all devices in the network because it does not know the DHCP server’s address yet.
Offer:
- After receiving the Discover message, the DHCP server replies with a DHCP Offer message. In this message, the server offers an available IP address and other network settings to the client device.
- The offered information may include IP address, subnet mask, default gateway, DNS server, and lease time.
Request:
- The client device receives the offered IP address and sends a DHCP Request message to the DHCP server. This message tells the server that the client wants to use the offered IP address.
- This step confirms the selection of the IP address.
Acknowledge (ACK):
- After receiving the Request message, the DHCP server sends a DHCP Acknowledge message, also called DHCP ACK. This message confirms that the IP address has been officially assigned to the client.
- Now the client device can communicate on the network and access internet services.
Real-Life Example:
Suppose you connect your mobile phone to your home Wi-Fi network. Your phone first sends a DHCP Discover message because it does not have an IP address. The Wi-Fi router, acting as the DHCP server, sends a DHCP Offer containing an available IP address. Your phone then sends a DHCP Request to accept the offered address. Finally, the router sends a DHCP ACK confirming the assignment. After this process, the phone can use the internet.
Summary
The DORA process is the main working method of DHCP. It helps devices automatically obtain IP addresses and network settings without manual configuration. This process makes network communication fast, simple, and efficient.
Real Example With IP Address:
DORA Process Example with IP Address Details
Suppose a laptop connects to an office Wi-Fi network for the first time. The laptop does not have an IP address, so it starts the DHCP DORA process to get network configuration from the DHCP server.
The DHCP server information is:
DHCP Server IP : 192.168.1.1
Available IP Range : 192.168.1.10 – 192.168.1.100
Subnet Mask : 255.255.255.0
DNS Server : 8.8.8.8
Discover:
The laptop does not have an IP address yet, so it sends a DHCP Discover message as a broadcast to find a DHCP server in the network.
At this stage:
Source IP : 0.0.0.0
Destination IP : 255.255.255.255
Message : DHCP Discover
The laptop is basically asking:
“Is any DHCP server available?”
Request:
The laptop accepts the offered IP address and sends a DHCP Request message to the server.
Now the laptop sends:
Requested IP : 192.168.1.10
Server IP : 192.168.1.1
Message : DHCP Request
The laptop is saying:
“I want to use IP address 192.168.1.10.”
Acknowledge (ACK):
The DHCP server confirms the assignment and sends a DHCP ACK message.
The server sends:
Assigned IP : 192.168.1.10
Subnet Mask : 255.255.255.0
Gateway : 192.168.1.1
DNS : 8.8.8.8
Lease Time : 24 Hours
Message : DHCP ACK
Now the laptop officially owns the IP address and can communicate on the network.
Complete Communication Flow:
Laptop DHCP Server
0.0.0.0 --------------------------> 255.255.255.255
DHCP Discover
IP Offer: 192.168.1.10
192.168.1.1 <---------------------- DHCP Offer
Request IP: 192.168.1.10 ----------> DHCP Request
192.168.1.1 <---------------------- DHCP ACK
IP Assigned Successfully
Final Result:
After the DORA process, the laptop receives:
IP Address : 192.168.1.10
Subnet Mask : 255.255.255.0
Default Gateway: 192.168.1.1
DNS Server : 8.8.8.8
Now the laptop can:
- Access the internet
- Communicate with other devices
- Open websites
- Use network services
What is a DHCP Lease
What is DHCP Lease:
A DHCP Lease is a temporary time period during which a device is allowed to use an IP address assigned by a DHCP server. The IP address is not permanent; it is given for a limited duration called the lease time.
Purpose of DHCP Lease:
The main purpose of DHCP lease is to efficiently manage IP addresses in a network. It ensures that IP addresses are not wasted and can be reused when a device disconnects from the network.
How DHCP Lease Works:
When a device connects to a network, the DHCP server assigns an IP address along with a lease time. For example, the server may assign IP 192.168.1.10 with a lease time of 24 hours. During this time, the device can use that IP address for communication.
Lease Renewal Process:
Before the lease time expires, the device automatically tries to renew the IP address from the DHCP server. If the server approves, the lease time is extended, and the device continues using the same IP address without interruption.
Lease Expiration:
If the device fails to renew the lease before it expires, the IP address becomes invalid. In this case, the device must restart the DHCP process (DORA) to get a new IP address from the server.
Real-Life Example:
When you connect your mobile phone to Wi-Fi, the router assigns an IP address like 192.168.0.25 with a lease time of 24 hours. Your phone can use this IP for that time period, and it will automatically renew it if still connected.
Importance of DHCP Lease:
DHCP lease is important because it helps reuse IP addresses, reduces IP wastage, and makes network management easier. It is especially useful in large networks where many devices connect and disconnect frequently.
DHCP Lease Example?
Example Scenario:
Suppose a laptop connects to an office Wi-Fi network. The DHCP server in the network automatically assigns an IP address along with other network settings.
For example, the laptop receives:
IP Address: 192.168.1.50
Subnet Mask: 255.255.255.0
Gateway: 192.168.1.1
DNS Server: 8.8.8.8
Lease Time: 24 Hours
Lease Usage:
The assigned IP address (192.168.1.50) is not permanent. The laptop is allowed to use this IP address only for the given lease time, which is 24 hours in this case. During this time, the device can freely access the network and internet.
Lease Renewal?
Before the lease expires, the laptop automatically tries to renew the IP address from the DHCP server. If the server approves the request, the lease time is extended, and the same IP address continues to be used without interruption.
Lease Expiration?
If the laptop does not renew the lease before the 24-hour period ends, the IP address becomes invalid. In that case, the device must request a new IP address again using the DHCP process.
Real-Life Example?
When you connect your mobile phone to home Wi-Fi, the router assigns an IP address like 192.168.0.20 with a lease time of 1 day. The phone uses this IP for that time and automatically renews it if it remains connected to the network.
Summary
A DHCP lease is a temporary assignment of an IP address to a device. It allows the device to use the IP for a specific time, after which it can be renewed or reassigned to another device, helping efficient use of IP addresses in a network.
What is DHCP Reservation
What is DHCP Reservation?
DHCP Reservation is a feature of DHCP where a specific IP address is permanently assigned to a particular device using its MAC address. Even though DHCP normally assigns dynamic IP addresses, reservation ensures a fixed IP for selected devices.
How It Works?
In DHCP reservation, the DHCP server stores the MAC address of a device and links it with a specific IP address. Whenever that device connects to the network, the server identifies its MAC address and always assigns the same reserved IP address.
Purpose of DHCP Reservation?
The main purpose of DHCP reservation is to provide a consistent and permanent IP address to important devices without manual configuration on the device itself. This helps in easy identification and stable network communication.
Example:
For example, an office printer has a MAC address like AA:BB:CC:11:22:33. The network administrator reserves IP address 192.168.1.100 for this printer. Every time the printer connects to the network, it will always receive this same IP address.
Real-Life Use:
DHCP reservation is commonly used for devices that need stable IP addresses, such as printers, servers, CCTV cameras, and network storage devices. This ensures that users can always access these devices using the same IP address.
Real-Life Example For Laptop:
When you connect your laptop to Wi-Fi, it normally gets different IPs each time. But if the admin sets DHCP reservation for your laptop, it will always receive the same IP like 192.168.1.50 every time it connects.
Summary:
DHCP reservation is a method of assigning a fixed IP address to a specific device using its MAC address. It combines the benefits of DHCP automation with the stability of a static IP address.
What is a DHCP Relay Agent
1. What is a DHCP Relay Agent?
A DHCP Relay Agent is a network device (usually a router or Layer-3 switch) that forwards DHCP requests from clients to a DHCP server located in another network. DHCP uses broadcast messages, and broadcasts normally cannot cross routers. The relay agent solves this problem by receiving the broadcast request and sending it to the DHCP server as a unicast message.
2. Why DHCP Relay Agent is Needed?
In large networks, the DHCP server is often placed in a central data center instead of every local network. Since DHCP discovery messages are broadcasts and routers block broadcasts between networks, clients in different subnets cannot reach the DHCP server directly. A DHCP relay agent forwards those requests so devices in other networks can still receive IP addresses automatically.
How a DHCP Relay Agent Works ?
1. DHCP Discover from Client
When a device (DHCP client) connects to a network, it does not have an IP address. The client sends a DHCP Discover message as a broadcast in the local network to find a DHCP server. The broadcast uses destination IP 255.255.255.255 and UDP port 67.
2. Relay Agent Receives the Broadcast
The router or Layer-3 switch configured as a DHCP Relay Agent receives the broadcast message from the client. Since routers normally do not forward broadcast packets to other networks, the relay agent captures this message and prepares to forward it to the DHCP server.
3. Forwarding Request to DHCP Server
The DHCP relay agent converts the broadcast request into a unicast packet and sends it to the DHCP server located in another network. It also adds its own interface IP address in the GIADDR (Gateway IP Address) field so the server knows from which subnet the request came.
4. DHCP Server Sends an Offer
After receiving the forwarded request, the DHCP server checks the subnet information and selects an available IP address from the correct address pool. The server then sends a DHCP Offer message back to the relay agent.
5. Relay Agent Sends Offer to Client
The DHCP relay agent receives the DHCP Offer from the server and forwards it to the client in the local network. The client then sees the offered IP address and network configuration.
6. Request and Acknowledge Process
The client sends a DHCP Request message to accept the offered IP address. The relay agent again forwards this request to the DHCP server. Finally, the server replies with a DHCP Acknowledge (ACK) message confirming the IP assignment, and the relay agent delivers this message to the client. The client can now use the assigned IP address to communicate on the network.
Example of DHCP Relay Agent
Suppose a company network has two subnets:
- Subnet 1: 192.168.1.0/24 (Office network)
- Subnet 2: 192.168.2.0/24 (Data center network)
The DHCP server is located in the data center network (192.168.2.10).
Step-by-step example:
- A computer in the office network sends a DHCP Discover broadcast.
- The office router acts as a DHCP relay agent.
- The router forwards the request to the DHCP server at 192.168.2.10.
- The DHCP server offers an IP address (for example 192.168.1.50).
- The router forwards the offer to the client.
- The client receives the IP address and can use the network.
Devices That Can Work as DHCP Relay Agent
Common devices used as DHCP relay agents include:
- Routers
- Layer-3 switches
- Firewalls
Example Command (Concept)
In many routers, the relay agent is configured with a command like:
ip helper-address 192.168.2.10
This tells the router to forward DHCP requests to the DHCP server at that IP address.
Router0 (Interface configuration)
.................................
enable
configure terminal
interface fastethernet 0/0
ip address 50.0.0.1 255.0.0.0
no shutdown
exit
interface serial 0/0/0
ip address 192.168.1.2 255.255.255.252
clock rate 64000
bandwidth 64
no shutdown
exit
interface serial 0/0/1
ip address 192.168.1.6 255.255.255.252
clock rate 64000
bandwidth 64
no shutdown
exit
Router0 (RIP routing configuration)
...................................
enable
configure terminal
router rip
network 50.0.0.0
network 192.168.1.0
network 192.168.4.0
version 2
no auto-summary
exit
Router1 (Interface configuration)
.................................
enable
configure terminal
interface fastethernet 0/0
ip address 10.0.0.1 255.0.0.0
no shutdown
exit
interface fastethernet 0/1
ip address 20.0.0.1 255.0.0.0
no shutdown
exit
interface serial 0/0/0
ip address 192.168.1.1 255.255.255.252
no shutdown
exit
(RIP routing configuration)
.............................
enable
configure terminal
router rip
network 10.0.0.0
network 20.0.0.0
network 192.168.1.0
version 2
no auto-summary
exit
ip helper-address
.................
interface fastethernet 0/0
ip helper-address 50.0.0.10
exit
interface fastethernet 0/1
ip helper-address 50.0.0.10
exit
Router2 (Interface configuration)
.................................
enable
configure terminal
interface fastethernet 0/0
ip address 30.0.0.1 255.0.0.0
no shutdown
exit
interface fastethernet 0/1
ip address 40.0.0.1 255.0.0.0
no shutdown
exit
interface serial 0/0/1
ip address 192.168.1.5 255.255.255.252
no shutdown
exit
(RIP routing configuration)
............................
enable
configure terminal
router rip
network 30.0.0.0
network 40.0.0.0
network 192.168.1.4
version 2
no auto-summary
exit
ip helper-address
.................
interface fastethernet 0/0
ip helper-address 50.0.0.10
exit
interface fastethernet 0/1
ip helper-address 50.0.0.10
exit
What is DHCP Failover
1. What is DHCP Failover
- DHCP Failover is a feature that allows two DHCP servers to share IP address management so that if one DHCP server fails, the other server can continue assigning IP addresses to clients. This ensures high availability and prevents network interruption.
- In simple terms, DHCP failover means backup DHCP servers working together to provide continuous IP address service.
2. Purpose of DHCP Failover
The main purpose of DHCP failover is to avoid network downtime. If a single DHCP server fails due to hardware issues, power failure, or network problems, devices will not receive IP addresses. With DHCP failover, another DHCP server automatically takes over the task and continues providing IP addresses to clients.
3. How DHCP Failover Works
- In DHCP failover, two DHCP servers share the same IP address pool and continuously synchronize their database. When one server assigns an IP address to a client, the information is also shared with the partner server. This ensures both servers have the same lease information.
- If the primary server stops working, the secondary server already has the lease data and can continue assigning IP addresses to new clients.
4. Types of DHCP Failover Modes
1. Load Balance Mode
In this mode, both DHCP servers are active and share the load of assigning IP addresses. Each server handles approximately 50% of the client requests, improving performance and redundancy.
2. Hot Standby Mode
In this mode, one server acts as the primary server, and the other server remains as a backup. The backup server only starts assigning IP addresses if the primary server fails.
5. Example of DHCP Failover
Suppose a company network has two DHCP servers:
- Server 1: DHCP Primary Server (IP: 192.168.10.2)
- Server 2: DHCP Secondary Server (IP: 192.168.10.3)
- IP Pool: 192.168.10.100 – 192.168.10.200
Step-by-step example:
- A new laptop connects to the network and sends a DHCP request.
- The primary DHCP server assigns IP 192.168.10.105 to the laptop.
- The lease information is automatically shared with the secondary server.
- If the primary server fails due to power loss, the secondary server continues assigning IP addresses from the same pool.
- Network users can still connect without interruption.
6. Advantages of DHCP Failover
- Provides high availability for IP address assignment
- Prevents network downtime
- Improves reliability of network services
- Provides automatic backup for DHCP servers
7. Real Network Example
Large enterprise networks and data centers often configure DHCP failover using server operating systems such as Windows Server or network infrastructure from Cisco Systems and Juniper Networks to ensure continuous DHCP services.
Why Need DHCP Server in Company Network
1. Automatic IP Address Assignment
- In a company network, many devices such as computers, laptops, printers, IP phones, and servers connect to the network. A DHCP server automatically assigns IP addresses and other network settings to these devices. Without DHCP, the network administrator would have to manually configure IP addresses on every device, which is time-consuming and error-prone.
- Example:
In an office with 200 computers, when employees connect their laptops to the LAN or Wi-Fi, the DHCP server automatically gives each device an IP address like 192.168.10.25, 192.168.10.26, etc.
2. Easy Network Management
- A DHCP server makes network management easier because all IP address assignments are controlled from a single server. If network settings such as DNS server or gateway need to change, the administrator can update them once on the DHCP server, and all clients will receive the new configuration automatically.
- Example:
If a company changes its DNS server, the network administrator updates the configuration on the DHCP server, and all computers receive the new DNS information when they renew their lease.
3. Prevents IP Address Conflicts
- When IP addresses are assigned manually, two devices may accidentally receive the same IP address, causing network problems. DHCP automatically tracks which addresses are already assigned and ensures each device gets a unique IP.
- Example:
If two employees manually set their IP address to 192.168.1.50, a conflict occurs. With DHCP, the server assigns different IPs, preventing this issue.
4. Supports Large Networks
- Large organizations may have hundreds or thousands of devices connecting to the network every day. DHCP makes it possible to manage these large networks efficiently without manually configuring every device.
- Example:
In a corporate office with 1000+ devices, the DHCP server manages the IP address pool and dynamically assigns addresses as devices connect and disconnect.
Without DHCP Server in Company Network
1. Manual IP Address Configuration
- Without a DHCP server, every device in the company network must be configured manually with an IP address, subnet mask, gateway, and DNS server. This takes a lot of time and effort for the network administrator.
- Example:
If a company has 300 computers, the administrator must manually set the IP address on each computer. This makes network management difficult.
2. IP Address Conflicts
- When IP addresses are assigned manually, two devices may accidentally use the same IP address. This causes IP address conflicts, and both devices may lose network connectivity.
- Example:
Two employees set their computers to 192.168.1.25 manually. Because both devices use the same IP address, they cannot communicate properly on the network.
3. Difficult Network Management
- Without DHCP, changing network settings becomes complicated. If the company changes the DNS server or default gateway, the administrator must update every device manually.
- Example:
If 200 computers need a new DNS server address, the administrator must log into each computer and change the configuration one by one.
4. Problems for New Devices
- When a new device joins the network, it cannot automatically get an IP address. The device will not connect to the network until the administrator manually configures it.
- Example:
A new employee brings a laptop to the office. Without DHCP, the laptop cannot access the network until the administrator sets the IP configuration.
5. Limited Scalability
- Large organizations may have hundreds or thousands of devices. Managing IP addresses manually in such large networks is inefficient and increases the chance of errors.
- Example:
In a company with 1000 devices, manual IP configuration would be very slow and difficult to maintain.
DHCP Pool And DHCP Scope
1. What is a DHCP Pool
- A DHCP Pool is a range of IP addresses that a DHCP server can automatically assign to devices (clients) in a network. The pool contains all the available IP addresses that can be given to computers, laptops, printers, and other devices when they connect to the network.
- The DHCP server selects an unused IP address from this pool and assigns it to a client for a specific lease time.
- Example:
If the DHCP pool is 192.168.1.100 – 192.168.1.200, the DHCP server can assign any IP address between these numbers to network devices.
2. What is a DHCP Scope
A DHCP Scope is the complete configuration of a network range managed by the DHCP server. It defines not only the IP address range but also other network parameters such as:
- IP address range
- Subnet mask
- Default gateway
- DNS server
- Lease duration
In simple terms, a scope is the network configuration, while the pool is the set of IP addresses inside that configuration.
Example:
A DHCP scope may be configured for the network 192.168.1.0/24, and inside that scope the DHCP pool may be 192.168.1.100 – 192.168.1.200.
Example of DHCP Pool and Scope
Network: 192.168.10.0/24
DHCP Scope Configuration:
- Network: 192.168.10.0
- Subnet Mask: 255.255.255.0
- Default Gateway: 192.168.10.1
- DNS Server: 8.8.8.8
- Lease Time: 24 hours
DHCP Pool:
Available IP range: 192.168.10.50 – 192.168.10.200
When a new computer connects to the network, the DHCP server assigns an IP from this pool.
DHCP Server Configuration on a Cisco Router and Switch
DHCP Configuration on a Cisco Router and Switch
1. DHCP Configuration on a Cisco Router:
To set up a Cisco router as a DHCP server, follow these steps:
Enter Global Configuration Mode:
Router> enable
Router# configure terminal
Define the DHCP Address Pool:
Create a DHCP pool with a name (e.g., LAN-Pool) and specify the IP address range, subnet mask, and other relevant settings.
Router(config)# ip dhcp pool LAN-Pool
Router(dhcp-config)# network 192.168.1.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.1.1 // Default Gateway IP
Router(dhcp-config)# dns-server 8.8.8.8 // DNS Server IP (optional)
Router(dhcp-config)# domain-name example.com // Domain name (optional)
Exclude IP Addresses (Optional):
It’s a good practice to reserve specific IP addresses (e.g., for servers, printers, or other devices) so they are not assigned dynamically by the DHCP server.
Use the ip dhcp excluded-address command:
Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.20
This excludes the IP range 192.168.1.1 to 192.168.1.20 from being assigned dynamically.
Verify DHCP Configuration:
To check the status of your DHCP server and the assigned IP addresses, use the following command:
Router# show ip dhcp binding
This shows the IP address leases that have been assigned to clients.
2. DHCP Configuration on a Cisco Switch:
In general, Cisco switches do not act as DHCP servers by default (unless they are Layer 3 switches or have additional services configured). However, you can configure a Layer 3 switch to act as a DHCP server or simply configure a switch to relay DHCP requests (using the ip helper-address command).
a) Configuring a Cisco Layer 3 Switch as a DHCP Server:
If you’re using a Layer 3 switch and want to configure it as a DHCP server, the process is very similar to configuring a router. Here’s an example:
Enter Global Configuration Mode:
Switch> enable
Switch# configure terminal
Define the DHCP Address Pool:
Switch(config)# ip dhcp pool VLAN10
Switch(dhcp-config)# network 192.168.10.0 255.255.255.0
Switch(dhcp-config)# default-router 192.168.10.1
Switch(dhcp-config)# dns-server 8.8.8.8
Exclude IP Addresses:
Switch(config)# ip dhcp excluded-address 192.168.10.1 192.168.10.10
Configure VLAN Interface:
The switch needs an IP address for the VLAN interface (SVI) to communicate with devices in that VLAN:
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.1 255.255.255.0
Switch(config-if)# no shutdown
Verify DHCP Configuration:
Switch# show ip dhcp binding
Switch# show ip dhcp pool
b) Configuring a Layer 2 Switch to Relay DHCP Requests:
In some cases, a Layer 2 switch (which doesn’t route traffic between different subnets) can relay DHCP requests from clients to a DHCP server on another network. This is done using the ip helper-address command, which forwards the DHCP requests to a specified DHCP server.
Enter Global Configuration Mode:
Switch> enable
Switch# configure terminal
Configure the Switch’s VLAN Interface (if needed):
If you want to configure the switch to be part of a VLAN (e.g., VLAN 10), configure the interface for that VLAN:
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.2 255.255.255.0
Switch(config-if)# no shutdown
Configure the ip helper-address Command:
Point the switch to the IP address of the DHCP server (assuming the DHCP server is located on a different subnet):
Switch(config)# interface vlan 10
Switch(config-if)# ip helper-address 192.168.1.1 // IP of the DHCP server
Verify Configuration:
To check the forwarding of DHCP requests, you can use the following:
Switch# show ip interface vlan 10
Conclusion:
Router as DHCP Server: If you’re using a Cisco router to assign IP addresses, you can configure the DHCP pool and set up exclusions to avoid assigning certain IPs.
Switch as DHCP Server: If you’re using a Layer 3 switch, it can act as a DHCP server, similar to a router.
Layer 2 Switch: A Layer 2 switch can forward DHCP requests to a DHCP server on a different network by using the ip helper-address command.
VLAN DHCP Configuartion
config t
ip dhcp pool 10
network 10.10.10.0 255.255.255.0
default router 10.10.10.1
dns-server 8.8.8.8
exit
config t
ip dhcp pool 20
network 10.10.20.0 255.255.255.0
default router 10.10.20.1
dns-server 8.8.8.8
exit
config t
ip dhcp pool 30
network 10.10.30.0 255.255.255.0
default router 10.10.30.1
dns-server 8.8.8.8
exit