Configuration and routing

Get network configuration

Understand how a host obtains addresses, prefixes, routers, and DNS server information.

8 minute lesson

~~~

A usable host configuration normally includes four pieces: an address, a prefix, routes, and DNS server information. The exact source can be static configuration or an automatic protocol, but a host needs all four to be genuinely online.

How IPv4 gets configured: DHCP

DHCP commonly supplies IPv4 configuration through a discover, offer, request, and acknowledgment exchange. Your machine broadcasts “anyone have an address for me?”, a DHCP server offers one, your machine formally requests it, and the server acknowledges. A lease gives the configuration a limited lifetime, after which the host must renew it.

On macOS you can read the actual lease your machine received:

ipconfig getpacket en0
yiaddr = 192.168.1.20
subnet_mask (ip): 255.255.255.0
router (ip_mult): {192.168.1.1}
domain_name_server (ip_mult): {192.168.1.1}
lease_time (uint32): 0x15180

There are the four pieces in one packet: your address (yiaddr), the prefix (as a subnet mask), the router, and the DNS server. The lease time 0x15180 is 86400 seconds — one day. On Linux, journalctl -u NetworkManager | grep -i dhcp or your distribution’s equivalent shows the same negotiation in logs.

How IPv6 gets configured: Router Advertisements

IPv6 hosts can learn prefixes and default routers from Router Advertisements. Stateless Address Autoconfiguration (SLAAC) lets a host form its own address for an advertised prefix — no server keeps a list of who has what.

Check the results:

ip -6 address show eth0
# inet6 2a01:e0a:4f2:1:8c3a:11ff:fe2b:940c/64 scope global dynamic
ip -6 route | grep default
# default via fe80::9e53:22ff:feaa:41e dev eth0 proto ra

The proto ra tag on the route means it was learned from a Router Advertisement, not typed in by anyone.

Verify the pieces agree

Configuration succeeded only when the pieces agree. An address without a suitable route may reach the local link but nowhere else. A working IP path without DNS can reach addresses but not resolve names.

A quick three-part check:

ip address        # do I have an address and prefix?
ip route          # do I have a default route?
dig example.com   # can I resolve names?

When someone says “the network is down”, run these three. Address present but no default route: local misconfiguration or DHCP handed out something incomplete. Address and route fine but dig times out: it’s DNS, not the network. Each failure pattern names its own culprit.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →