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.

MAC Addresses and IP Addresses: What Is the Difference, and Why Does a Phone Use Different MAC Addresses on Different Wi-Fi Networks?

Category: Technology

Even with the same smartphone, the device's local network identifier, called a MAC address, can be different when you connect to home Wi-Fi versus café Wi-Fi. If the name tag changes, why does communication still reach the other party? In fact, name tags are swapped many times while data travels. In standard router forwarding, the part that does not change is the IP address, which acts like a mailing address. This note explains the difference between these two roles and why name tags are changed.

1. Why a Phone Uses a Different MAC Address for Each Wi-Fi Network

Apple's support page explains that devices like the iPhone, iPad, Mac, and Apple Watch use different addresses for each Wi-Fi network. This is because if the same address were used continuously, network providers could easily link the device's movements and location [7]. Android devices use random MAC addresses by default for Wi-Fi connections on version 10 and later [6].

If communication continues even when the name tag changes, there must be a separate "destination" for the communication that is not the name tag. That is the IP address. So, what do these two things refer to?

2. How a MAC Address (Name Tag) and an IP Address (Address) Differ

Let us compare this to a delivery service. The IP address is the "address" of the final destination for the package. The MAC address identifies the device receiving the package on the current part of its journey. However, the analogy and reality differ slightly. The IP standard (RFC 791) distinguishes between "what a name searches for," "where the address is located," and "how the route is taken" [1]. The MAC address is not a "name" but a number used to identify devices within the range connected by the same line.

IPv4 addresses are 32 bits long and are treated as divided into a part indicating the network and a part indicating the device within that network [1]. This is similar to a town name and a house number. However, where the division occurs (the prefix length) is determined by settings and is not fixed [9].

MAC addresses (EUI-48) are 48 bits long. In the MA-L allocation, they are created by adding 24 bits determined by an organization to a 24-bit identifier (OUI) assigned by the IEEE to that organization [2]. Not all addresses follow this structure. For addresses in this allocation, the first half identifies the organization assigned the number range.

3. How a Device Finds the Recipient's MAC Address Inside the Same Network

When sending to a recipient within the same network, the label stuck on the box is the recipient's name tag (MAC address). However, you often only have the recipient's IP address on hand. Therefore, ARP (Address Resolution Protocol) is used. ARP was created to distribute the correspondence between addresses like IP and 48-bit Ethernet addresses as needed [3]. It is a mechanism for asking, "What is the MAC address of the owner of this IP?" within the range connected by the same line.

If the answer is known, you can stick that name tag on and hand over the box. So, what happens when the recipient is in a different town?

4. How a Router Replaces the MAC Address but Keeps the IP Address When Forwarding

This is the most important point of this note. When a router forwards a package, it first removes the link layer header received (the part containing the MAC address destination and source), adjusts the IP header, and attaches a new link layer header for the next recipient [4].

In other words, during the journey, the MAC address changes at each step of the journey. On the other hand, in standard router forwarding, the IP source and destination are maintained [4]. If a home router uses NAT (address translation), the IP is also rewritten. The "adjusted" IP header includes a limit on the number of trips (TTL). Routers discard data when the TTL reaches 0 [4]. This prevents data from looping through the network forever.

If the name tag changes every time, is the name tag itself that is replaced not very important?

5. How Changing MAC Addresses Makes Location Tracking Harder

MAC addresses are sent without encryption. Therefore, Android documentation explains that they can be used for location tracking [6]. In Android, the locally administered bit is set to 1, the unicast (one-to-one destination) bit is set to 0, and the remaining 46 bits are randomized [6]. This means even the part determined by the manufacturer is randomized.

The same idea applies to IP addresses. The method for automatically generating addresses in IPv6 (SLAAC) can include identifiers that do not change over time, which can be used for correlation (linking communications to the same device). Therefore, "temporary addresses" that change over time were proposed to limit the period during which tracking is possible [8]. By the way, IPv6 increased the number of address bits from 32 to 128. While the number of bits is 4 times larger, the total number of addresses is not 4 times larger, but 2 to the power of 96 times larger [5].

6. How to Check Your Phone's Wi-Fi Addresses Yourself

How to Check Your Phone's Wi-Fi Addresses Open the Wi-Fi settings screen on your smartphone and look at the details of the network you are currently connected to. The goal is to check if the name tag is random by looking at the items on the screen. There may be items named "Private Address" or "Random." The display names differ by device, so do not worry if you cannot find them. Just look, and do not change any settings. It is reassuring to look together with an adult.

If you want to read the materials: Apple's support page provides an explanation of Private Wi-Fi addresses [7]. If you use Android, the AOSP documentation summarizes the behavior [6].

Sources

  1. RFC 791 Internet Protocol https://www.rfc-editor.org/rfc/rfc791.txt (Structure of IP addresses and distinction between name, address, and route.)
  2. IEEE Registration Authority, OUI https://standards.ieee.org/products-programs/regauth/oui/ (Composition of MAC addresses.)
  3. RFC 826 An Ethernet Address Resolution Protocol https://www.rfc-editor.org/rfc/rfc826.txt (Purpose of ARP.)
  4. RFC 1812 Requirements for IP Version 4 Routers https://www.rfc-editor.org/rfc/rfc1812.txt (Router forwarding and TTL.)
  5. RFC 8200 Internet Protocol, Version 6 (IPv6) Specification https://www.rfc-editor.org/rfc/rfc8200.txt (Address length of IPv6.)
  6. Android Open Source Project, MAC randomization behavior https://source.android.com/docs/core/connect/wifi-mac-randomization-behavior (Behavior and reason for MAC randomization.)
  7. Apple Support "Private Wi-Fi Address" https://support.apple.com/ja-jp/102509 (Wi-Fi addresses on Apple devices.)
  8. RFC 8981 Temporary Address Extensions for Stateless Address Autoconfiguration in IPv6 https://www.rfc-editor.org/rfc/rfc8981.txt (Temporary addresses in IPv6.)
  9. RFC 4632 Classless Inter-domain Routing (CIDR) https://www.rfc-editor.org/rfc/rfc4632.txt (Network part division by prefix length.)