Skip to main content

DHCP

Dynamic Host Configuration Protocol

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/dhcp

In short

DHCP is a network protocol that automatically gives devices an IP address and other settings, such as the router and DNS server, when they join a network.

What is DHCP?

DHCP, the Dynamic Host Configuration Protocol, is how most devices get their network settings automatically. When a laptop, phone, or server joins a network, a DHCP server hands it an IP address, a subnet mask, the address of the default gateway (the router), and the DNS servers to use. Without DHCP, someone would have to type these settings into every device by hand and make sure no two devices got the same address.

The exchange has four steps, often remembered as DORA: the new device broadcasts a Discover message, a server replies with an Offer, the device sends a Request for that address, and the server confirms with an Acknowledge. The address is not given forever but leased for a set time, such as 24 hours, and the device renews the lease before it expires, so addresses from devices that leave can be reused. DHCP for IPv4 runs over UDP, with servers listening on port 67 and clients on port 68.

Think of a hotel front desk: when you check in, you get a room number for the length of your stay, and when you leave, the room goes back to the pool for the next guest. In home networks, the router usually acts as the DHCP server, while offices and data centers run dedicated servers, and cloud platforms use DHCP to hand out addresses to virtual machines.

DHCP is often confused with DNS. DHCP gives a device its IP address and network settings, while DNS translates domain names such as example.com into IP addresses; DHCP simply tells the device which DNS server to ask. Because DHCP addresses can change, servers and printers usually get a reservation, a fixed address that the DHCP server always gives to that device, or a static IP address configured on the device itself.

Key takeaways

  • DHCP automatically assigns IP addresses and network settings to devices.
  • The four-step exchange is Discover, Offer, Request, Acknowledge (DORA).
  • Addresses are leased for a limited time and renewed before they expire.
  • DHCP for IPv4 uses UDP ports 67 (server) and 68 (client).
  • A DHCP reservation gives a device the same address every time.

Example

A small DHCP server configuration (dnsmasq)ini
# dnsmasq.conf: a DHCP server for a small home or lab network
interface=eth0

# Hand out addresses from .100 to .200, each leased for 24 hours
dhcp-range=192.168.1.100,192.168.1.200,24h

# Settings sent to every client along with its address
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.1

# Reservation: the device with this MAC address always gets .10
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.1.10

Readers ask

What is the difference between DHCP and DNS?

DHCP gives a device its IP address and network settings when it joins a network. DNS translates domain names into IP addresses, and DHCP is usually what tells a device which DNS server to use.

What is a DHCP lease?

A lease is the period of time a device is allowed to use the IP address it was given, such as 8 or 24 hours. The device renews the lease automatically before it expires and usually keeps the same address.

What happens if a DHCP server is unavailable?

A device may keep using an address whose lease hasn't expired yet, or it falls back to a self-assigned link-local address in the 169.254.0.0/16 range. That address only works on the local network segment, so the device typically has no internet access.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings