How IP Addresses, DNS, and DHCP Work
Read a device's IP address, mask, gateway and DNS servers, explain how DHCP hands them out and how DNS finds names, and spot the setting that points to a fault.
Table of contents
Every device on a network needs four settings: an IP address, a subnet mask, a default gateway and at least one DNS server. DHCP hands those settings out, and DNS turns names into addresses. When a user says "the internet is down," one of these four is wrong far more often than the internet is. Once you know what each one means, you can tell in seconds whether a device's settings make sense. Steps were checked on Windows 11, version 26H2, and macOS 27 (Golden Gate).
What You Will Be Able to Do
- Read an IPv4 address and subnet mask, and tell whether two devices are on the same network.
- Explain what the default gateway does.
- Tell private, public, link-local and loopback addresses apart.
- Describe how DHCP hands out addresses, leases and reservations, and what goes wrong with it.
- Explain how DNS finds the address for a name, and which DNS servers a company computer must use.
The Four Settings Every Device Needs
| Setting | Example | What it does |
|---|---|---|
| IP address | 192.168.1.50 | The device's own address |
| Subnet mask | 255.255.255.0 | Marks which part is the network |
| Default gateway | 192.168.1.1 | The router to other networks |
| DNS server | 192.168.1.10 | Looks up addresses for names |
Static settings are typed in by hand. Dynamic settings come from a DHCP server. Most computers, laptops and phones use DHCP. Servers and network gear keep fixed addresses so everyone can find them.
IPv4 Addresses
An IPv4 address is 32 bits, written as four numbers from 0 to 255 separated by dots, such as 192.168.1.50. Each number is an octet, because it stands for 8 bits. Part of the address names the network, and the rest names the device, called the host.
Subnet Masks and Prefixes
The subnet mask marks where the network part ends. Where the mask says 255, that octet belongs to the network. Where it says 0, it belongs to the host. The same mask is often written as a prefix length, a slash and the number of network bits. 255.255.255.0 has 24 network bits, so it is written /24, as in 192.168.1.50/24. This is CIDR notation.
| Prefix | Mask | Usable addresses |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /23 | 255.255.254.0 | 510 |
| /22 | 255.255.252.0 | 1,022 |
| /16 | 255.255.0.0 | 65,534 |
Every network gives up two addresses: the first, the network address, names the network, and the last, the broadcast address, reaches every device on it at once.
Worked Example: Same Network or Not
A laptop has 192.168.1.50 with the mask 255.255.255.0 (/24).
- The mask covers the first three octets, so the network is 192.168.1.0.
- Usable hosts run from 192.168.1.1 to 192.168.1.254. The broadcast address is 192.168.1.255.
- A printer at 192.168.1.200 is on the same network. The laptop sends to it directly.
- A server at 192.168.2.10 is on a different network, because the third octet differs. The laptop hands that traffic to the default gateway.
With a /23 mask (255.255.254.0), the network runs from 192.168.0.0 to 192.168.1.255, so 192.168.0.40 is local too. A wrong mask causes odd, partial failures, so compare the mask with a working neighbor's.
The Default Gateway
The default gateway is the router that carries traffic from the local network to every other network, including the internet.
- It must be on the same network as the device. A laptop at 192.168.1.50/24 with a gateway of 192.168.2.1 can never reach it.
- It is often .1 or .254, but that is a habit. Read the real value.
- A device with no gateway can reach its local neighbors, but nothing beyond them.
Special Address Ranges
| Range | Kind | Meaning on a ticket |
|---|---|---|
| 10.0.0.0/8 | Private | Normal inside a network |
| 172.16.0.0/12 | Private | Normal inside a network |
| 192.168.0.0/16 | Private | Normal inside a network |
| 169.254.0.0/16 | Link-local | Usually no DHCP answer |
| 127.0.0.0/8 | Loopback | The device talking to itself |
Private addresses, set aside by the RFC 1918 standard, are for use inside networks. The 172.16.0.0/12 block runs only from 172.16.0.0 to 172.31.255.255. The internet does not route these, so offices everywhere reuse them. On the way out, the router uses network address translation (NAT) to swap each private address for the business's public address, the one its internet provider assigned. That is why a "what is my IP" website shows a different address from the computer's settings. Both are correct.
Link-local addresses come from RFC 3927. A device gives itself one in 169.254.0.0/16 when no DHCP server answers. Windows calls this Automatic Private IP Addressing (APIPA), and macOS reports a self-assigned IP address. These addresses never leave the local link. On a ticket, a 169.254 address almost always means a DHCP problem or no working connection, not a broken computer.
Loopback, usually 127.0.0.1, is the device's network software talking to itself. It works even with the cable unplugged.
A Short Word on IPv6
IPv6 addresses are 128 bits, written in hexadecimal groups separated by colons, such as 2001:db8::50, where the double colon stands for a run of zeros. Every IPv6 adapter has an fe80:: link-local address even when everything works, so unlike 169.254 it does not mean a failure. ::1 is the IPv6 loopback.
MAC Addresses
Every network adapter also has a MAC address, a hardware address of 12 hexadecimal digits, such as 00:1a:2b:3c:4d:5e. Windows labels it Physical Address. The IP address changes from network to network, but the MAC address identifies the adapter on the local network. Devices use the Address Resolution Protocol (ARP) to learn which MAC goes with a local IP address, and arp -a lists what a Windows PC or Mac has learned.
Phones, tablets and some laptops use a private Wi-Fi address, a random MAC for each Wi-Fi network, to protect the user's privacy. That matters for reservations.
How DHCP Hands Out Addresses
DHCP (Dynamic Host Configuration Protocol) gives devices their settings automatically. A router, a Windows server or a firewall usually runs it.
The Four Messages
A joining device trades four messages with a DHCP server, remembered as DORA:
- Discover. The device broadcasts a request for a DHCP server.
- Offer. A server answers with an available address and settings.
- Request. The device asks to use that offer.
- Acknowledge. The server confirms, and the device starts using the address.
The server listens on UDP port 67, and the device on UDP port 68. The first message is a broadcast, so it stays on the local network unless a router is set up to relay it to a DHCP server elsewhere.
Leases
An address from DHCP is a lease, good for a length of time the server sets. Under the DHCP standard, RFC 2131, the device tries by default to renew with the same server at the halfway point. If that server does not answer, it asks any server at seven-eighths (87.5 percent) of the lease. If the lease runs out with no answer, it must stop using the address. With an 8-hour lease, that is 4 hours (8 x 0.5) and 7 hours (8 x 0.875).
Scopes, Exclusions and Reservations
- A scope, or pool, is the range the server may hand out, such as 192.168.1.100 to 192.168.1.199.
- An exclusion is part of that range the server must never hand out, kept for static devices.
- A reservation ties one address to one MAC address, so that device always gets the same address.
| Method | Good for | Watch out for |
|---|---|---|
| DHCP | Computers, laptops, phones | A down server stops new leases |
| Reservation | Printers, cameras, door controllers | A private MAC never matches |
| Static | Servers, routers, switches | Must sit outside the scope |
If a phone or tablet uses a private Wi-Fi address, a reservation for its real MAC never matches. With your policy's approval, turn off the private address for that network on that device, or reserve the MAC it really reports.
What Goes Wrong With DHCP
| Symptom | Likely cause | First move |
|---|---|---|
| 169.254 address | No DHCP answer | Check the link, then other users |
| Address from the wrong range | Rogue DHCP server | Compare with a neighbor, report it |
| IP address conflict warning | Static address inside the scope | Find the static device |
| New devices get nothing | Scope full | Escalate to the network admin |
A rogue DHCP server, most often a home router plugged into an office jack, hands out its own range with itself as the gateway, and a whole area can lose access at once.
Warning: Do not change the address of a server, printer or network device, or edit a DHCP scope, without your team's approval. Other systems point at those addresses, and one change can stop a whole floor from printing or signing in.
How DNS Turns Names Into Addresses
People use names like mail.example.com. Networks use addresses. DNS (Domain Name System) is the directory that connects the two. When you type a name, the device:
- Checks its cache, a short-term memory of recent answers, and its hosts file, a small local list of names. On Windows that file is
C:\Windows\System32\drivers\etc\hosts. On a Mac it is/etc/hosts. - Asks the DNS server in its settings, called a resolver.
- If the resolver has no cached answer, it works down from a root server to the servers for the ending, such as .com, and then to the authoritative server that holds the domain's real answer.
- The resolver passes the answer back, and both keep a copy in cache.
Every answer carries a time to live (TTL), the number of seconds it may stay in a cache. That is why a DNS change takes a while to reach everyone, and why a computer can keep using a site's old address until its cache clears.
| Record | Holds | Example use |
|---|---|---|
| A | An IPv4 address | www to 203.0.113.20 |
| AAAA | An IPv6 address | www to 2001:db8::20 |
| CNAME | Another name (an alias) | help to a vendor's name |
| MX | The domain's mail server | Where email is delivered |
| TXT | Text | Email sender checks, domain proof |
| SRV | Where a service runs | Finding domain controllers |
DNS on a Company Network
Businesses that use Active Directory, Microsoft's directory of users and computers, run their own DNS servers, usually on the domain controllers. Domain computers find domain controllers through DNS, so Microsoft's guidance is to point them at the domain's DNS servers, not an internet provider's, and let those servers pass outside lookups on.
Setting a work laptop's DNS to a public resolver, such as 8.8.8.8 or 1.1.1.1, "to fix the internet" is a common mistake. Websites load, but file servers, printers and the domain stop resolving, and domain sign-in can fail.
One test works anywhere: if a device reaches something by its address but not by its name, the problem is DNS.
Reading a Device's Settings
Windows 11: Open Start > Settings > Network & internet, then select Wi-Fi and your network, or Ethernet, to see the IPv4 address. For everything, run ipconfig /all in Command Prompt or PowerShell.
macOS 27: Open Apple menu > System Settings > Network, select the service, such as Wi-Fi, then click Details and TCP/IP. In Terminal, networksetup -getinfo "Wi-Fi" shows the address, mask and router, and scutil --dns lists the DNS servers. The older ifconfig shows the mask in hexadecimal, so 0xffffff00 means 255.255.255.0.
Worked Example: Decoding ipconfig /all
A user says cloud email works, but the shared drive does not. Here is part of their ipconfig /all, trimmed to fit:
Ethernet adapter Ethernet:
Physical Address : 00-1A-2B-3C-4D-5E
DHCP Enabled : No
IPv4 Address : 10.20.30.45
Subnet Mask : 255.255.255.0
Default Gateway : 10.20.30.1
DNS Servers : 8.8.8.8
- DHCP Enabled: No. Someone typed these settings by hand, while the rest of the floor uses DHCP.
- Address, mask and gateway. 10.20.30.45/24 is private, on network 10.20.30.0, and the gateway is on the same network. Fine.
- DNS: 8.8.8.8. A public resolver. Websites and cloud email work, but it has never heard of the internal file server. This is the fault.
With your team's approval, set the adapter back to get its address and DNS automatically, confirm the shared drive opens, and note the change in the ticket.
Common Mistakes
| Mistake | What it costs |
|---|---|
| Treating 169.254 as a broken PC | Hours of reinstalling while DHCP stays broken |
| A static address inside the scope | An IP conflict that knocks devices offline |
| Public DNS on a domain computer | Lost file shares, printers and sign-in |
| Writing the public IP on the ticket | The wrong device gets investigated |
Check Your Understanding
1. A laptop shows the address 169.254.88.12. What does that tell you, and where do you look first?
No DHCP server answered, so it gave itself a link-local address. Check its connection and network first, then whether nearby users get addresses.
2. A PC at 172.16.5.20 with mask 255.255.255.0 needs a server at 172.16.6.8. Does that traffic go through the gateway?
Yes. The PC's network is 172.16.5.0, and the server's third octet is 6, so it is on another network.
3. A user's settings show 192.168.10.33, but a website says their IP is 203.0.113.77. Which is wrong?
Neither. The first is the private address inside the office. The second is the office's public address, which the router uses for everyone through NAT.
4. Two PCs keep showing IP address conflict warnings. Last week someone typed 10.1.4.120 into one of them by hand, and the DHCP scope runs from 10.1.4.100 to 10.1.4.199. What went wrong?
The hand-typed address sits inside the scope, so DHCP leased the same address to another device. With your team's approval, move the static device outside the scope or add an exclusion.
Key Takeaways
- A device needs an address, a mask, a gateway and DNS, and most problems show up in one of those four.
- The mask decides what is local. Anything else goes to the gateway.
- A 169.254 address means DHCP never answered. An fe80:: address in IPv6 is normal.
- DHCP leases renew at the halfway point, and a reservation follows the MAC address.
- If an address works and a name does not, suspect DNS. Domain computers use the company's DNS servers.