This site is only a doorway

Everything here is gathered from things other people actually researched, thought through, and built: books, papers, historical records, and the people behind them. If something here catches your interest, go look at the original sources listed at the bottom of the page. They carry more depth than a page like this ever can.

How Does Your Phone Get an IP Address When It Joins a Network?

Category: Technology

When you connect to Wi-Fi at a friend's house, you only type a password. You do not enter settings for IP addresses or DNS. Yet, the internet works immediately. How does this happen?

This article traces the few exchanges that happen just before your phone connects. It explains the system called DHCP, which assigns numbers to devices, and why those numbers have an "expiration date."

1. Why Every Device Needs an IP Address to Connect

To communicate on the internet, every device needs a number called an "IP address." Like a home address for a letter, without this number, replies cannot reach you. However, the IP address is not the only setting needed. Your phone also requires a subnet mask, which shows how far the network extends. It needs a default gateway, which acts as the exit to the outside world. It also needs the location of a DNS server, which looks up numbers from names. DHCP is the system that automatically provides these settings for IPv4 networks.[1]

As the number of devices grows, setting these details by hand becomes difficult. DHCP helps your phone receive these settings, so you do not need to type the numbers yourself to connect to the net.

2. How a Phone Asks for an Address Before It Has One

There is a small problem here. To get a number, the phone must ask someone. But the phone does not have its own number yet, and it does not know who is in charge of assigning numbers. So, the phone calls out in a way that reaches everyone on the same network. This is called a broadcast. The name of this call is "DHCPDISCOVER."[2]

Imagine arriving at a hotel and asking loudly in the lobby, "Is there a free room?" In reality, this is not a voice. It is small data sent through radio waves or cables. Because the phone cannot choose a specific destination, it must address everyone. The person in charge of numbers replies.

3. The Four Steps DHCP Uses to Assign an IP Address

The typical flow for receiving a new number has four stages. Sometimes, steps are skipped.[2] Continuing the hotel example: 1. DISCOVER: The phone calls out to everyone, "Please give me a number." 2. OFFER: The DHCP server suggests, "How about this number?" 3. REQUEST: The phone applies, "I want to borrow that number." 4. ACK: The server confirms, "Then it is decided with that number," and sends the settings.

These four stages are sometimes called "DORA." This is a common nickname used in explanations, but it is not a term found in the official standard text. The standard recommends that the server check if the number is already in use before giving it. For example, it can send a call to that number to see if a reply comes back.[2] However, this is a recommendation, not a rule. Actual devices may behave differently.

4. How DHCP Leases Addresses and Renews Them Over Time

The number you receive is not yours forever. DHCP uses a concept called a "lease," which lends numbers with a time limit. When the time runs out, the device stops using the number, and the server can lend it to other devices.[4] This method is useful in places where the number of available addresses is limited, or where many devices connect temporarily.[4] It is like borrowing a library book or renting a locker. The length of the loan depends on the device and its settings.

Does communication stop suddenly when the time runs out? No. To prevent this, the phone acts on its own. When half the time has passed (called T1), it asks the original server directly, "Please extend the loan." If there is no reply, when 7/8 of the time has passed (T2), it calls out to other servers to ask for an extension until the deadline.[5] For example, if the deadline is 8 hours, T1 is 4 hours later, and T2 is 7 hours later. These ratios are default guidelines and can be changed by settings.

5. What a Device Does When No DHCP Server Answers

What if you call out "Please give me a number," but no one replies? In that case, the device may choose a number for itself from the range starting with "169.254." This is called a link-local address. These numbers only allow communication between devices connected to the same line. Routers do not forward traffic addressed to these numbers.[6]

Therefore, you can talk to other devices in that spot, but you cannot go out to the internet. If your device shows a number starting with "169.254," it is a sign that you are not talking to the number manager. However, behavior varies by device, so treat this as a rough guide.

6. Private Addresses and How They Help Reduce Tracking

In private networks like homes or offices, there are ranges of numbers that do not need to be unique worldwide. These are called "private addresses." There are three ranges: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. The second range includes 172.16 to 172.31.[7] One goal is to save the number of addresses.

DHCP servers may use MAC addresses (unique device identifiers) to recognize devices. JPNIC explains two ways to run this: giving a fixed number based on a registered MAC address, or automatically assigning from a range.[1] Related to this, Apple has a feature called "Private Wi-Fi Address." It uses a different MAC address for each Wi-Fi network. This makes it harder for operators and others to track a device's actions or location.[8] This is a setting on the device, not a function of DHCP itself.

7. How to Check Your Phone's IP Address in Wi-Fi Settings

Open the detailed information for the Wi-Fi you are connected to in your phone's settings. You might find a number starting with "192.168" or "10." You can compare it with the numbers in this article to see if it is in the private address ranges. Look only. Do not change settings. Do not take photos of passwords or other private information to share. Screens differ by model, so ask an adult if you cannot find it. Compare your number with family devices to see if it falls into one of the three private ranges or starts with "169.254."

Sources

  1. JPNIC, "Internet Terminology 1-Minute Explanation: DHCP" https://www.nic.ad.jp/ja/basics/terms/dhcp.html (Explains the definition of DHCP, the types of settings distributed, and operational methods.)
  2. R. Droms, "Dynamic Host Configuration Protocol", RFC 2131, 1997. https://www.rfc-editor.org/rfc/rfc2131 (Covers the 4-step exchange, checking if an address is in use, and its status as a standard.)
  3. pynetlabs, "What is DHCP" https://www.pynetlabs.com/what-is-dhcp/ (Discusses the destination address for DISCOVER messages. Secondary source.)
  4. "Dynamic Host Configuration Protocol", RFC 1541, 1993. https://www.rfc-editor.org/rfc/rfc1541 (Covers assignment with lease times, reclamation, and its status as a predecessor standard.)
  5. R. Droms, RFC 2131 Section 4.4.5. https://datatracker.ietf.org/doc/html/rfc2131#section-4.4.5 (Defines the renewal times T1 and T2.)
  6. "Dynamic Configuration of IPv4 Link-Local Addresses", RFC 3927. https://www.rfc-editor.org/rfc/rfc3927 (Covers self-configured addresses starting with 169.254.)
  7. "Address Allocation for Private Internets", RFC 1918. https://www.rfc-editor.org/rfc/rfc1918 (Covers the three ranges of private addresses.)
  8. Apple Support, "Use Private Wi-Fi Address" https://support.apple.com/ja-jp/102509 (Covers the feature that uses different identifiers for each Wi-Fi network.)