DNS
A name is found by asking down a tree, then remembered
A recursive resolver asks the root, the TLD and the authoritative server: 71 ms the first time, 4 ms from cache until the TTL runs out.
People use names; packets need addresses. DNS turns one into the other. The laptop asks one recursive resolver for www.example.com. If the resolver has no answer cached, it asks a root server, which says: ask the .com servers. The .com server says: ask example.com’s own servers. The authoritative server gives the address. 71 milliseconds in all. The resolver keeps each answer for its time to live, so the next lookup takes 4.
DNS · Going deeper · 1 of 2
The record types and what each answers
A and AAAA give addresses, CNAME an alias, MX the mail server, NS the name servers, PTR the name for an address.
DNS · Going deeper · 2 of 2
Private and genuine DNS: DoT, DoH and DNSSEC
DoT (853) and DoH (443) encrypt lookups; DNSSEC signs records so forged answers fail.
DHCP
Four messages give a new device its address and settings
DHCP leases an address in four steps, DORA. A 24-hour lease renews at 12 hours; with no server, a client falls back to APIPA, 169.254.x.x.
A device that joins a network has no address and does not know who to ask. So it broadcasts a Discover from address zero. A DHCP server offers an address. The client broadcasts a Request for that offer, so any other server knows it was not chosen. The server acknowledges, with the mask, gateway, DNS servers and a lease time. Halfway through the lease, the client renews.
DHCP · Going deeper
Relaying DHCP across a router
A DHCP relay (ip helper-address on the client-facing interface) forwards broadcasts as unicast with giaddr, so one server serves every subnet.
NAT and PAT
One public address shared by giving each connection its own port
PAT (NAT overload) rewrites private source addresses and ports to one public address, tracking each pair in a translation table.
Private addresses cannot cross the internet, and public ones are scarce. So the edge router translates. When a host sends a packet out, the router replaces the private address and port with its own public address and a free port, and writes the pair in a table. Three hosts become three ports on one address. The server sees only the router’s address. Replies come back to that address and port, the router looks them up, and passes each to the right host.
NAT and PAT · Going deeper
NAT terms, kinds and configuration
Inside local is the private address, inside global the public one. Static NAT publishes a server; PAT with overload shares one address.
NTP
Four timestamps let every device agree on the time
NTP (UDP 123) uses four timestamps to find the offset, 120 ms here, and the delay. Stratum counts the hops from the reference clock.
Logs from a hundred devices are useless if their clocks disagree. NTP arranges clocks in strata: a GPS or atomic reference is stratum zero, the server wired to it is stratum one, and each step down adds one. The client stamps the time it sends, the server stamps when it receives and replies, and the client stamps the reply’s arrival. From those four numbers, the client works out that its clock is 120 milliseconds slow, separately from the 20 milliseconds the network took, and corrects itself.
Ports
Every service has a port, and most have a secure twin
Know the well-known ports: SSH 22, DNS 53, DHCP 67/68, HTTP 80, NTP 123, SNMP 161/162, LDAPS 636, RDP 3389, and each plain-text protocol’s encrypted replacement.
Down the left, protocols that send everything as readable text, each beside the encrypted protocol that replaced it. Telnet became SSH, FTP became SFTP, HTTP became HTTPS, LDAP became LDAPS. On the right, the infrastructure services every network runs: DNS on fifty-three, DHCP on sixty-seven and sixty-eight, NTP on a hundred and twenty-three, SNMP on a hundred and sixty-one, and remote desktop on thirty-three eighty-nine.
Ports · Going deeper
How an email travels
Mail is submitted on 587, relayed on 25 to the domain’s MX server, and read over IMAP (993) or POP3 (995).
Device management
Manage devices only over encrypted channels
Use SSH instead of Telnet, SNMPv3 instead of v1 or v2c, and SCP or SFTP instead of TFTP or FTP.
Capture a Telnet session and you can read the password. Capture SSH and you see noise. SNMP lets a monitoring server ask a device for its counters on port one sixty-one, and the device report events on one sixty-two. Versions one and two send a community string as plain text; version three adds users and encryption. The same holds for copying files: TFTP and FTP are readable, SCP and SFTP run inside SSH.
Lesson complete
You finished “DNS, DHCP and NAT”
Nicely done.