2.2DNS, DHCP & how the internet works
The essentials in 30 seconds
- DHCP automatically hands out the address, the mask, the gateway and the DNS servers: the assignment is a lease, renewed periodically.
- DNS translates names (example.com) into IP addresses — the Internet's directory; without it, the network works but sites are unreachable by name.
- No address (169.254) → DHCP; address OK but name KO → DNS: two diagnostic reflexes by elimination.
Running mini-case — Sofiane isolates the DNS in Algiers
Sofiane, a support technician in a distribution SME in Algiers, receives a ticket: “the delivery-tracking site no longer opens”, even though email works. Instead of suspecting everything, he tests: ping 8.8.8.8 answers, but ping suivis-livraison.dz returns “host not found”. He deduces a name-resolution problem: the DHCP placed the workstation correctly (valid address, gateway supplied, DNS server assigned), but name → address translation fails. He flushes the DNS cache, tries another DNS server, and access returns. He restates the full chain: the DHCP gives the address and the DNS server, then the DNS resolves each name before the connection.
Standalone case for this section: it returns in the lesson, the diagram, the script and the 48h challenge of section 2.2.
1. DHCP — the automatic address
DHCP (Dynamic Host Configuration Protocol) automatically hands out to the machines joining the network their IP address, their mask, their gateway and their DNS servers. It is thanks to it that a computer connects and “works” without manual configuration. The assignment is a lease (a duration): the machine “borrows” the address and renews it. If the DHCP does not answer, the machine ends up without a valid address (169.254.x.x, cf. 2.1).
2. DNS — the Internet's directory
DNS (Domain Name System) translates the readable names (e.g. example.com) into IP addresses that machines actually use. Every time a site is opened, the device queries a DNS server: “what is the address of this name?”. Without DNS, the network works but sites become unreachable by their name — a very recognisable symptom, which Sofiane isolated precisely.
3. The full chain and diagnosis by elimination
At start-up: the DHCP gives the machine an address and the address of a DNS server. Then, as soon as a name is used, the DNS resolves it to an address and the connection is established (client-server model). Two reflexes settle it: no address at all (169.254) → suspect the DHCP; address OK but the name does not open (while the IP answers) → suspect the DNS.
🔎 Concrete example — 🔎 Concrete example — “The Internet half-works”
A user opens a site by its IP address, but not by its name; Sofiane tests:
> ping 8.8.8.8 -> reply OK
> ping example.com -> "host not found"
Reading : network + gateway OK (the IP answers)
Diagnosis : name -> address translation failing = DNS problem
Reading: the network and the gateway work (the IP answers); only the name → address translation fails.
Lesson: try another DNS server or flush the DNS cache — without touching the cabling or the addressing, which are healthy.
Section vocabulary
- DHCP
- Automatically assigns IP address, mask, gateway and DNS servers to the machines joining the network.
Simple example: Thanks to the DHCP, Sofiane's workstation configures itself on connection.
What it is not: an IP configuration typed entirely by hand.
Reflex: automatic address → DHCP.
- DNS
- Translates domain names (example.com) into IP addresses — the Internet's directory.
Simple example: Sofiane tests a name to check that the DNS answers.
What it is not: the service that hands out the network's IP addresses.
Reflex: name → address → DNS.
- Name resolution
- The operation of translating a name into an address, performed by the DNS.
Simple example: The resolution of suivis-livraison.dz fails: Sofiane suspects the DNS.
What it is not: the assignment of a DHCP lease to a new workstation.
Reflex: translate a name → resolution.
- DHCP lease
- Duration during which a machine “borrows” its address, then renews it.
Simple example: The workstation's lease expires and renews automatically.
What it is not: a fixed address set by hand forever.
Reflex: borrowed and renewed address → lease.
- DNS server
- Machine that answers name → address questions; its address is often supplied by the DHCP.
Simple example: Sofiane tries another DNS server to restore access.
What it is not: the router that performs the NAT to the outside.
Reflex: who answers names → the DNS server.
In practice — In practice — Spotting DNS and DHCP on a workstation
- Display the configuration (ipconfig /all): note the assigned DNS servers, like Sofiane.
- Check that the address was obtained automatically (mention DHCP enabled).
- Test the resolution of a name, then compare with a test by IP address.
- Conclude by elimination: no address → DHCP; name KO but IP OK → DNS.
Step-by-step script — deciding between DNS and DHCP like Sofiane (4 min)
1) Run ipconfig /all: note the address and the DNS servers. 2) Check that the address is normal (no 169.254) and was indeed obtained via DHCP. 3) Test ping 8.8.8.8 (an IP), then ping a site name. 4) If the IP answers and not the name: it is the DNS — flush the cache (ipconfig /flushdns) then try another DNS server. 5) If no valid address: it is the DHCP — check the link then the renewal.
Remember the order: first DHCP (the address and the DNS are assigned), then DNS (each name is translated).
Copy-paste template — my DNS / DHCP sheet
DHCP : assigns IP + mask + gateway + DNS servers (lease)
DNS : translates a name (example.com) into an IP address
Test : ping 8.8.8.8 (IP) then ping a name
No address (169.254) -> DHCP
Name KO but IP OK -> DNS
DNS workaround: flush the cache, try another DNS server
The site no longer opens by its name
Sofiane tests by IP: it answers. Resolution fails → DNS lead, cache flushed.
No address assigned
The workstation falls back to 169.254: Sofiane looks at the DHCP side and renews the lease.
Some things work, others do not
Email works but not the web: Sofiane first checks name resolution.
A DNS server to change
Resolution stays temperamental: Sofiane tries another DNS server, often the first workaround.
✓ Best practices
- Keep DHCP by default for the workstations.
- Note the DNS servers used to react fast.
- When in doubt, test by IP to isolate a DNS problem.
✗ Common pitfalls
- Confusing DNS and DHCP.
- Believing “no more Internet” while only the DNS is at fault.
- Forgetting the DNS cache (a stale entry).
Key takeaways
- DHCP = automatic address; DNS = names → addresses.
- Site unreachable by name but OK by IP → DNS.
- No address (169.254) → DHCP.
- The web works on a request-response basis (client-server).
48h challenge — apply it tomorrow
Like Sofiane, reproduce the sequence: ping an IP (e.g. 8.8.8.8) then ping a site name. Note both results and conclude in one sentence: if the IP answers and not the name, the failure is DNS. Then specify the workaround you would apply (flush the DNS cache or change the DNS server).
- I can explain the role of the DHCP and that of the DNS.
- I can decide between a DNS problem and a DHCP problem.
- I know the workarounds: flush the DNS cache, change the DNS server.
Frequently asked questions
What is the difference between DNS and DHCP?
DHCP answers “what is my address?”; DNS answers “where is this name?”. First DHCP (address + DNS server), then DNS (resolution).
“The Internet is down” but some things work — how to decide?
It works by IP but not by name → DNS. Nothing at all / 169.254 → DHCP or physical link. A single app down → it is not the network.
What is the DNS for?