# DHCP

> The service that gives each device an IP address automatically when it joins a network.

- Level: Intermediate
- Topics: Networks
- URL: https://tidbit.legios.com.ar/dhcp/
- In Spanish: [DHCP](https://tidbit.legios.com.ar/es/dhcp/)

**DHCP** (Dynamic Host Configuration Protocol) is why you can walk into a café, pick the Wi-Fi and be online a second later without typing any numbers. When a device joins a network, it shouts 'is there a DHCP server here?'. The server, usually built into the router at home or a dedicated machine at an office, answers with an IP address that is free, and the device accepts it.

The answer contains more than the address. It also says which addresses are local (the subnet mask), which router to send everything else to (the default gateway) and which DNS servers to use for looking up names. Before DHCP, someone had to type all of that by hand into every computer, and two machines given the same address would knock each other offline.

The address is a **lease**, not a gift: it is lent for a while, from minutes to days, and the device quietly renews it while it stays. When it leaves, the address goes back to the pool for the next visitor. Printers and servers that need to be found at the same place every day get a **reservation**: the server always hands that device, recognized by its MAC address, the same IP address.

When something goes wrong, DHCP is a common suspect. If your computer shows an address starting with `169.254`, it asked and nobody answered, so it gave itself a placeholder that cannot reach the internet. Restarting the router or turning Wi-Fi off and on usually triggers a fresh request.

## An analogy

The front desk of a hotel. You arrive, they hand you a room key, tell you where breakfast is and when checkout is, and when you leave the room goes to the next guest.

## Keep in mind

- Hands out an IP address, the gateway and the DNS servers automatically.
- Addresses are leased for a time and renewed while the device stays.
- At home, the router is almost always the DHCP server.
- An address starting with `169.254` means the device got no answer.

## Go deeper

- [DHCP on Wikipedia](https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol)
- [Dynamic Host Configuration Protocol (Microsoft Learn)](https://learn.microsoft.com/en-us/windows-server/networking/technologies/dhcp/dhcp-top)

## Related terms

- [Wi-Fi](https://tidbit.legios.com.ar/wi-fi/): Networking over radio waves: the internet without the cable, within a few rooms.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Router](https://tidbit.legios.com.ar/router/): The box that connects your devices to each other and to the internet.
- [IP address](https://tidbit.legios.com.ar/ip-address/): The number that identifies a device on a network, like a postal address.
- [Subnet](https://tidbit.legios.com.ar/subnet/): A slice of a network's IP addresses, grouped so its devices can talk directly.
- [DNS](https://tidbit.legios.com.ar/dns/): The internet's phone book: it turns names like wikipedia.org into IP addresses.
- [MAC address](https://tidbit.legios.com.ar/mac-address/): The built-in name of a network card, used to deliver data inside a local network.
- [Internet](https://tidbit.legios.com.ar/internet/): A worldwide network of networks that lets any connected device reach any other.
