BIT451 Network and System Administration

Network and System AdministrationUnit 410 min read

DHCP: Leases, Scopes, Relays & Troubleshooting

Unit 4 of Network and System Administration covers the Dynamic Host Configuration Protocol (DHCP), including its operation, message types, scope configuration, relay agents, troubleshooting techniques, and real-world applications in Nepalese networks like eSewa, Ncell, and NTC. This note explains how DHCP automates IP

What is DHCP?

Definition and Purpose

Dynamic Host Configuration Protocol (DHCP) is a network management protocol used to automate the assignment of IP addresses, subnet masks, default gateways, and other network configuration parameters to devices on a network. Without DHCP, network administrators would manually configure each device, which is impractical in large networks.

Why DHCP?

  • Efficiency: Eliminates manual IP assignment.
  • Scalability: Easily manages thousands of devices.
  • Flexibility: Allows reuse of IP addresses (leases).
  • Centralized Management: Configurations can be updated centrally.

How DHCP Works: The 4-Way Handshake

DHCP operates using a client-server model with four key message types exchanged between a DHCP client (e.g., laptop, smartphone) and a DHCP server (e.g., router, dedicated server). The process is called DORA:

  1. Discover: Client broadcasts a DHCPDISCOVER to find available DHCP servers.
  2. Offer: Server responds with a DHCPOFFER (proposed IP and lease time).
  3. Request: Client accepts with a DHCPREQUEST (unicast to server).
  4. Acknowledge: Server confirms with a DHCPACK (finalizes lease).
sequenceDiagram
    participant Client as DHCP Client (e.g., Laptop)
    participant Server as DHCP Server (e.g., Router)
    Client->>Server: 1. DHCPDISCOVER (Broadcast)
    Server->>Client: 2. DHCPOFFER (Unicast)
    Client->>Server: 3. DHCPREQUEST (Unicast)
    Server->>Client: 4. DHCPACK (Unicast)
    Note over Client,Server: Lease begins (e.g., 8 hours)

DHCP Scope and Configuration

Scope: The Pool of IPs

A DHCP scope is a range of IP addresses assigned by the DHCP server. Key components:

  • Start/End IP: Range of assignable IPs (e.g., 192.168.1.100 to 192.168.1.200).
  • Subnet Mask: Defines the network portion (e.g., 255.255.255.0).
  • Default Gateway: Router IP for client communication (e.g., 192.168.1.1).
  • DNS Servers: IP addresses of DNS resolvers (e.g., 8.8.8.8, 8.8.4.4).
  • Lease Time: Duration before IP must renew (e.g., 8 hours, 24 hours).
  • Exclusions: IPs reserved for static devices (e.g., printers, servers).

Example: Ncell Hotspot DHCP Scope

  • Scope Range: 10.0.0.100 to 10.0.0.200
  • Subnet Mask: 255.255.255.0
  • Gateway: 10.0.0.1
  • DNS: 8.8.8.8, 1.1.1.1
  • Lease Time: 12 hours
  • Exclusions: 10.0.0.1 (router), 10.0.0.2 (firewall)

DHCP Relay Agent

In large networks (e.g., NTC’s nationwide fiber backbone), DHCP clients and servers may be on different subnets. A DHCP relay agent (often a router) forwards DHCPDISCOVER/DHCPREQUEST messages to the server and returns replies to the client.

How It Works:

  1. Client broadcasts DHCPDISCOVER (limited to its subnet).
  2. Relay agent captures the packet, strips the client’s MAC, and forwards it to the server with its own giaddr field.
  3. Server replies to the relay agent (not the client).
  4. Relay agent forwards DHCPACK to the client.
sequenceDiagram
    participant Client as Client (Subnet A)
    participant Relay as Relay Agent (Router)
    participant Server as DHCP Server (Subnet B)
    Client->>Relay: DHCPDISCOVER (Broadcast)
    Relay->>Server: DHCPDISCOVER (giaddr=Relay IP)
    Server->>Relay: DHCPOFFER (to giaddr)
    Relay->>Client: DHCPOFFER (Broadcast)

DHCP Options: Customizing Leases

DHCP options are additional configuration parameters sent to clients. Common options:

Option Code Description Example Value
Router 3 Default gateway 192.168.1.1
DNS 6 DNS server addresses 8.8.8.8, 1.1.1.1
Domain 15 Search domain example.com
Lease 51 Lease time (seconds) 3600 (1 hour)
NTP 42 Network Time Protocol server time.google.com

Example: eSewa’s DHCP Option 42 (NTP)

  • Ensures all eSewa payment terminals sync time for transaction logging.
  • Option 42: time1.google.com, time2.google.com

DHCP Troubleshooting

Common Issues and Fixes

Issue Cause Solution
No IP assigned DHCP server down Check server logs, restart service
IP conflict Duplicate IP in scope Exclude conflicting IP or renew lease
Slow response time Overloaded DHCP server Increase lease time or add more servers
Client not receiving options Incorrect option configuration Verify dhcpd.conf or router ACLs

Worked Example: NTC Fiber Outage

  • Problem: Users on a NTC fiber subnet lose internet after 5 hours.
  • Root Cause: DHCP lease time set to 5 hours, but no renewal mechanism.
  • Fix:
    1. Extend lease time to 24 hours in DHCP scope.
    2. Configure dhcp-renewal-time to 75% of lease (e.g., 18 hours).
    3. Test with ipconfig /release and ipconfig /renew (Windows) or dhclient -r (Linux).

Tools for Troubleshooting

  • dhcpdump: Captures and analyzes DHCP traffic.
  • tcpdump: Filters DHCP packets (tcpdump -i eth0 port 67 or 68).
  • ipconfig /all (Windows) or ifconfig (Linux): Checks assigned IP and lease details.
  • Router Logs: Verify relay agent forwarding.

DHCP vs. Static IP: Comparison

Feature DHCP Static IP
Assignment Automatic Manual
Flexibility High (reuses IPs) Low (fixed to device)
Scalability Excellent (thousands of devices) Poor (administrative overhead)
Security Vulnerable to spoofing More secure (controlled)
Use Case Laptops, phones, IoT devices Servers, printers, routers

When to Use Static IP in Nepal?

  • Nepal Stock Exchange (NEPSE) servers: Must have fixed IPs for trading systems.
  • Bank ATMs: Require static IPs for secure transactions.
  • Firewalls/routers: Need predictable IPs for ACLs.

In the Real World

1. eSewa’s DHCP for Payment Terminals

  • Idea Used: DHCP scopes with Option 42 (NTP) and Option 6 (DNS).
  • How It Works:
    • eSewa deploys 10,000+ payment terminals nationwide.
    • DHCP server assigns IPs from 172.16.0.100–200 with a 2-hour lease.
    • Option 42 ensures all terminals sync time with time.esewa.com for audit trails.
    • Option 6 points to eSewa’s internal DNS (dns.esewa.com) for transaction validation.

2. Ncell’s DHCP Relay for 4G Hotspots

  • Idea Used: DHCP relay agents in multi-subnet networks.
  • How It Works:
    • Ncell’s core network (subnet 10.0.0.0/8) has DHCP servers in Kathmandu.
    • Edge routers in Pokhara, Biratnagar, and Dhangadi act as relay agents.
    • When a user connects to a hotspot in Dhangadi (subnet 192.168.10.0/24), the relay forwards DHCPDISCOVER to Kathmandu.
    • Server replies with an IP from 10.10.10.100–200 and a 12-hour lease.

3. Daraz’s Warehouse Inventory System

  • Idea Used: DHCP + VLANs for segmentation.
  • How It Works:
    • Daraz’s warehouse network uses VLAN 10 for inventory scanners and VLAN 20 for management PCs.
    • DHCP server on VLAN 10 assigns IPs from 172.17.10.50–150 (lease: 1 hour).
    • DHCP relay on the core switch forwards requests to the server.
    • Static IPs are reserved for printers (e.g., 172.17.10.1) and firewalls (172.17.10.2).

Worked Example: Configuring DHCP on a Router

Scenario: Configure a Cisco router as a DHCP server for a small office with:

  • Subnet: 192.168.1.0/24
  • Exclude: 192.168.1.1 (router), 192.168.1.2 (printer)
  • Lease time: 1 day
  • DNS: 8.8.8.8, 1.1.1.1
  • Default gateway: 192.168.1.1

Steps:

enable
configure terminal
ip dhcp pool OFFICE_POOL
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 8.8.8.8 1.1.1.1
lease 1
exclude-address 192.168.1.1 192.168.1.2
end
write memory

Verification:

show ip dhcp binding
show running-config | section ip dhcp

Exam Tip

What Examiners Want to See

  1. DORA Process: Always draw or describe the 4-way handshake (Discover, Offer, Request, Acknowledge).
  2. Scope Configuration: List 5 key parameters (range, subnet, gateway, DNS, lease time) in your answer.
  3. Troubleshooting Steps: Use a table to match symptoms to causes/solutions (e.g., "No IP assigned → DHCP server down").
  4. Real-World Tie-Ins: Relate DHCP to Nepalese examples (e.g., "Ncell uses relay agents for hotspots").
  5. Options: Know Option 3 (router), 6 (DNS), 42 (NTP), and one more (e.g., Option 15 for domain name).
  6. Static vs. DHCP: Compare 3 features (scalability, security, use cases) with examples.

Common Pitfalls to Avoid:

  • Forgetting broadcast vs. unicast in DORA (e.g., DHCPDISCOVER is broadcast).
  • Ignoring lease time in calculations (e.g., "Why does a client lose IP after 8 hours?").
  • Confusing DHCP relay with DNS forwarding (they serve different protocols).

Sample Exam Question: "Explain how DHCP resolves IP conflicts. Illustrate with a scenario where a laptop and printer are assigned the same IP in a school network." Your Answer Should Include:

  1. Definition of IP conflict.
  2. How DHCP detects it (DHCPNAK message).
  3. Steps for resolution (client releases IP, requests new one).
  4. Mermaid sequence diagram of the conflict resolution.
  5. Real-world example: "In a school lab, a printer and laptop both get 192.168.1.50; the DHCP server sends DHCPNAK to the laptop, which then requests a new IP."

stateDiagram-v2
    [*] --> DHCP_Client_Active
    DHCP_Client_Active --> DHCPDISCOVER: Broadcast
    DHCPDISCOVER --> DHCP_SERVER_OFFER: Server responds
    DHCP_SERVER_OFFER --> DHCPREQUEST: Client accepts
    DHCPREQUEST --> DHCPACK: Server confirms
    DHCPACK --> IP_ASSIGNED: Lease begins
    IP_ASSIGNED --> LEASE_EXPIRED: After lease time
    LEASE_EXPIRED --> DHCPREQUEST: Client renews
    DHCPREQUEST --> DHCPACK: Server extends lease
    DHCPACK --> IP_ASSIGNED
    IP_ASSIGNED --> IP_CONFLICT: Duplicate IP detected
    IP_CONFLICT --> DHCPNAK: Server sends rejection
    DHCPNAK --> DHCPDISCOVER: Client retries

Based on the TU BIT syllabus for Network and System Administration (BIT451), unit 4.

Discussion

Loading…