When your phone joins Wi-Fi, it broadcasts a DHCPDISCOVER. The router responds with an offer: "here's an IP from my pool, here's the gateway, here are the DNS servers, lease length 24 hours."
IPv6 has two parallel mechanisms: SLAAC (StateLess Address Auto-Configuration) where the device builds its own address from a router advertisement, and DHCPv6 which works more like the IPv4 version.
See also
- IPv4The original 32-bit IP addressing scheme — addresses look like 203.0.113.42 and there are ~4.3 billion of them.
- IPv6The 128-bit successor to IPv4 — addresses look like 2001:db8::1 and there are 2^128 of them.
- DNSThe distributed directory that maps human-readable names like example.com to IP addresses (and other records).
