DHCP (Dynamic Host Configuration Protocol) - secuguru/security-terms GitHub Wiki

DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to automatically assign IP addresses and other network configuration details (such as subnet mask, default gateway, and DNS server addresses) to devices on a network. This automation simplifies network management, especially in environments with a large number of devices.

How DHCP Works

DHCP operates based on a client-server model. The DHCP server manages a pool of IP addresses and configuration data, while DHCP clients (such as computers, smartphones, printers, etc.) request network configuration when they connect to the network.

Here’s the typical process of how DHCP works:

  1. DHCP Discover:
  • When a device (DHCP client) joins a network, it broadcasts a DHCP Discover message to find a DHCP server. The message is sent to the entire network because the client doesn’t yet have an IP address.
  1. DHCP Offer:
  • The DHCP server receives the discover request and responds with a DHCP Offer message. This message includes an available IP address, subnet mask, lease duration, and other network configuration details.
  1. DHCP Request:
  • The client responds to the DHCP offer by sending a DHCP Request message to the server, indicating that it accepts the offered IP address and configuration.
  1. DHCP Acknowledgment:
  • The DHCP server confirms the assignment by sending a DHCP Acknowledgment (ACK) message. This message finalizes the process, allowing the client to use the assigned IP address for a specific lease period.

At this point, the client is configured with an IP address and other necessary network settings, enabling it to communicate on the network.

Key DHCP Concepts

  1. IP Lease:
  • DHCP assigns IP addresses for a specific period, known as the lease duration. Once the lease expires, the client must either renew the lease or request a new IP address. This allows efficient use of a limited number of IP addresses.
  1. DHCP Lease Renewal:
  • Before the lease expires, the client can send a DHCP Request to the server to renew its IP address lease, keeping the same configuration without interruption.
  1. DHCP Scope:
  • A DHCP scope defines the range of IP addresses that a DHCP server can assign to clients. For example, a scope could be the range 192.168.1.100 to 192.168.1.200, meaning the server can assign any address within that range.
  1. DHCP Reservations:
  • A reservation ensures that a specific client always receives the same IP address. This is useful for devices like printers or servers that need a consistent IP address for stability.

DHCP Lease Types:

  • Dynamic Lease:
    • The dynamic lease process means the IP address is temporarily assigned (leased) to a device.
    • The lease has a specific duration, after which it expires, and the device must request a new lease or renew the existing one.
  • Automatic Lease:
    • The automatic lease keeps track of MAC address and IP address pairings in a table.
    • If the same device (with the same MAC address) reconnects, it is likely to receive the same IP address it had previously been assigned.
  • Manual Lease (Static IP):
    • In manual mode, an administrator configures a device to always receive a specific static IP address from the DHCP server.
    • This is ideal for devices like servers and network printers that need a persistent, unchanging IP address.

DHCP in IPv4 vs. IPv6

  • In IPv4, DHCP dynamically assigns IP addresses from a pool of available addresses.
  • In IPv6, a similar protocol called DHCPv6 is used for address assignment, although IPv6 also supports stateless address autoconfiguration (SLAAC), which allows devices to configure their own IP addresses without a DHCP server.

DHCP Ports:

  • Port 67: The DHCP server listens on port 67 for incoming client requests. This is where devices send their initial request to obtain an IP address.
  • Port 68: The DHCP client listens on port 68 to receive responses from the DHCP server, such as IP address offers or lease renewals.

DHCPv6 Ports:

  • Port 546: Used by the DHCPv6 client to receive offers or information from a DHCPv6 server.
  • Port 547: Used by the DHCPv6 server to listen for requests from clients.

Advantages of DHCP

  • Automates Network Configuration: Reduces the need for manual IP address configuration, minimizing errors.
  • Efficient IP Address Allocation: Ensures that IP addresses are used efficiently by reassigning unused addresses.
  • Simplifies Network Management: Particularly in large networks where managing IP addresses manually would be time-consuming.

Disadvantages of DHCP

  • Single Point of Failure: If the DHCP server goes down, new devices won’t be able to join the network unless they’re manually configured.
  • Security Concerns: DHCP lacks built-in authentication, making it susceptible to attacks like DHCP spoofing, where a rogue server can assign incorrect IP addresses or network settings.

Use Cases

  • Home Networks: Routers typically act as DHCP servers, automatically assigning IP addresses to devices like computers, phones, and smart TVs.
  • Corporate Networks: Enterprises use DHCP servers to dynamically assign IP addresses to employees’ devices, simplifying network management and IP address allocation.

In summary, DHCP simplifies the process of assigning IP addresses and network configuration settings, making network management more efficient and reducing the potential for errors in both small and large networks.