
Recall first from Recovery and startup measurement
- Optimize boot from a measured dependency chain and a product readiness requirement.
- A failed unit is a starting point; locate the failing boot layer before restarting, since repeated restarts erase context.
- Socket activation requires an application that accepts the passed file descriptor; timers prevent overlap but are not real-time deadlines.
Interfaces and the layers of connectivity
4 min readThe previous lesson taught service and journal inspection. This lesson answers how interfaces, IPv4 prefixes, gateways and DNS connect a host to the network and resolve names.
The previous lesson taught service and journal inspection. A board's service can start correctly yet fail to send measurements. Restarting cannot repair an unplugged cable, incorrect route or rejected connection. Check each boundary between application and peer.
A network interface is a kernel-visible attachment through which a system sends and receives network traffic. Ethernet and Wi-Fi interfaces can attach to hardware; virtual interfaces implement software connections. The loopback interface, lo, carries traffic locally. A packet is a unit of network-layer data carrying addressing information and a payload. An Ethernet frame wraps a packet with link-layer information for one local delivery.
A port is a transport-layer number that identifies a communication endpoint within a protocol and IP-address context. Transport protocols carry communication between applications. A socket is a kernel communication endpoint referenced by a process through a file descriptor. A file descriptor is a process-local handle, as introduced in earlier lessons.
Transmission Control Protocol, TCP, provides an ordered byte stream with connection state and retransmission. User Datagram Protocol, UDP, exchanges datagrams without TCP's handshake or delivery guarantees. TCP port 53 and UDP port 53 are distinct endpoints.
Start with read-only inspection:
ip -brief link
ip -brief addr
ip -s link show dev eth0
ip link show dev eth0
ip_vti0@NONE DOWN
ip6_vti0@NONE DOWN
sit0@NONE DOWN
ip6tnl0@NONE DOWN
ip6gre0@NONE DOWN
eth0@if139 UP 172.17.0.2/16
learner@embeddex:~/lab$ # Read flags separately from operational state
learner@embeddex:~/lab$ ip link show dev eth0
11: eth0@if139: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT g
roup default
link/ether 86:de:0d:5e:ca:46 brd ff:ff:ff:ff:ff:ff link-netnsid 0
learner@embeddex:~/lab$ # Add byte, packet, error and drop counters
learner@embeddex:~/lab$ ip -s link show dev eth0
11: eth0@if139: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT g
roup default
link/ether 86:de:0d:5e:ca:46 brd ff:ff:ff:ff:ff:ff link-netnsid 0
RX: bytes packets errors dropped missed mcast
690 7 0 0 0 0
TX: bytes packets errors dropped carrier collsns
84 2 0 0 0 0
learner@embeddex:~/lab$Replace eth0 with the reported name, such as enp1s0, end0 or wlan0. Names alone do not prove hardware type. The ip command belongs to iproute2, replacing net-tools commands ifconfig and route for this workflow.
Read the flags separately from the displayed operational state. UP inside angle brackets means administratively enabled. LOWER_UP means the driver reports its lower layer operational, commonly Ethernet carrier. An administratively enabled Ethernet interface can still have no carrier. DORMANT can indicate waiting for an event such as network authentication. UNKNOWN, often seen for loopback, is not automatically failure. These distinctions follow the kernel operational-state model.
ip -s link adds byte, packet, error and drop counters. Compare them around a controlled test. Drop counters alone do not locate loss: driver, queue and later processing accounting differ. Inspect power, cable, switch port, radio association and firmware before changing addresses.
sudo ip link set dev eth0 up temporarily enables an interface without assigning an address or authenticating Wi-Fi. Preserve the interface carrying your SSH session.
A VM may use a virtual switch or translated network. WSL networking also depends on Windows policy. Neither proves the board's physical Ethernet works. BusyBox builds may supply a reduced ip applet; check ip --help and include full iproute2 in the image when needed.
IPv4 prefixes, gateways and route selection
4 min readInternet Protocol version 4, IPv4, uses 32-bit addresses commonly written as four decimal octets. Each octet represents eight bits and ranges from 0 to 255. Our isolated example network uses board address 192.168.50.20/24 and router 192.168.50.1. These are example private addresses; use the addresses allocated to your actual lab.
Classless Inter-Domain Routing notation writes an address followed by the number of leading bits in its network prefix. Here /24 corresponds to netmask 255.255.255.0. Bitwise AND of address and mask gives network 192.168.50.0. In an ordinary /24, .0 identifies the network and .255 is the broadcast destination; neither is a host assignment. The usable range is .1 through .254. Do not apply that subtraction rule indiscriminately to special /31 point-to-point links or /32 host routes.
With /20, the mask is 255.255.240.0, so the third octet advances in blocks of 16. Address 192.168.50.20/20 belongs to 192.168.48.0/20, not 192.168.50.0/20. A wrong prefix can make the board try local delivery for a destination that should go through a router.
A gateway is a router used as the next hop toward a destination beyond a directly reachable network. Linux normally needs an on-link path to the gateway itself. A default route, 0.0.0.0/0, is the fallback; a more specific selected route can handle off-subnet destinations.
ip -4 addr show dev eth0
ip -4 route show
ip -4 route get 192.168.50.1
ip -4 route get 198.51.100.10
ip rule show
valid_lft forever preferred_lft forever
learner@embeddex:~/lab$ # Show the IPv4 routing table
learner@embeddex:~/lab$ ip -4 route show
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2
learner@embeddex:~/lab$ # Ask the kernel for the route to the gateway
learner@embeddex:~/lab$ ip -4 route get 192.168.50.1
192.168.50.1 via 172.17.0.1 dev eth0 src 172.17.0.2 uid 1000
cache
learner@embeddex:~/lab$ # Ask the kernel for the route to a remote address
learner@embeddex:~/lab$ ip -4 route get 198.51.100.10
198.51.100.10 via 172.17.0.1 dev eth0 src 172.17.0.2 uid 1000
cache
learner@embeddex:~/lab$ # List policy rules that select routing tables
learner@embeddex:~/lab$ ip rule show
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
learner@embeddex:~/lab$198.51.100.10 is a documentation address. ip route get asks the kernel for a route without sending a probe. Read the device, next hop and source address. Policy rules select routing tables; within the applicable table the longest matching prefix wins, with metrics helping choose comparable routes. Multiple uplinks need deliberate routing policy.
Select route: Match the destination using routing policy and the applicable table.
Choose source: Select an appropriate local address and output interface.
Select next hop: Use the gateway for a routed destination, or the destination itself for an on-link route.
Resolve neighbor: Discover the next hop's local hardware address when the link requires it.
Transmit frame: Send the frame to that hardware address while retaining the remote IP destination.
Forward onward: The router repeats routing decisions toward the final host.
IPv6 uses 128-bit addresses, separate routes and Neighbor Discovery instead of IPv4 ARP, the local address-resolution protocol explained below. Diagnose families separately with ip -6 addr, ip -6 route, and client -4 or -6 options; an IPv4 firewall does not protect IPv6.
The Domain Name System is a distributed naming system that answers queries for records, including mappings from hostnames to IP addresses. DNS translates a name; routing then handles the resulting address. Address, prefix, gateway and DNS configuration solve different parts of reaching a named service.
Configure persistent addressing through its owner
3 min readDynamic Host Configuration Protocol leases network configuration, such as an IPv4 address, prefix, router and DNS servers, from a server. A lease is time-limited and renewed. A DHCP reservation assigns a predictable address from the server side. Static configuration assigns it locally; coordinate it with the address pool to prevent duplicates. A static address alone supplies neither a default route nor name resolution.
1Identify the configuration owner
systemctl is-active NetworkManager systemd-networkd
nmcli device status
networkctl list
ls /etc/netplan
NetworkManager manages connection profiles through nmcli or the terminal interface nmtui. systemd-networkd consumes .network files. Netplan reads YAML, an indentation-based format, and generates settings for a renderer, usually networkd or NetworkManager. Debian's ifupdown reads /etc/network/interfaces. Missing components reveal your image's choices. Competing owners for one interface create unstable results.
2Understand a temporary experiment
Only on an isolated, console-accessible interface with no competing manager, an example is:
sudo ip link set dev eth0 up
sudo ip addr add 192.168.50.20/24 dev eth0
sudo ip route replace default via 192.168.50.1 dev eth0
The address normally creates an on-link prefix route. The default-route command can replace your existing default and disconnect you; record the original first. To undo, delete the exact added address with ip addr del and restore the recorded default route. Do not flush all addresses. These commands do not persist across reboot and do not configure DNS.
3Choose one persistent method
For a Netplan-owned Ethernet interface, edit its existing definition rather than layering conflicting files. A complete example is:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
addresses: [192.168.50.20/24]
routes:
- to: default
via: 192.168.50.1
nameservers:
addresses: [192.168.50.1]
This assumes the router also provides DNS. Use root-owned files under /etc/netplan/ with restricted permissions, such as mode 600. Run sudo netplan generate to check generation, then sudo netplan try from a recoverable console. Try offers a confirmation timeout and rollback, but verify actual rollback after a failure; it is not a substitute for recovery access. Follow the Netplan examples for the installed release.
For NetworkManager, find the existing profile name, then adapt this example where it is lab-wired:
nmcli connection show
sudo nmcli connection modify lab-wired ipv4.method manual \
ipv4.addresses 192.168.50.20/24 ipv4.gateway 192.168.50.1 \
ipv4.dns 192.168.50.1 ipv4.ignore-auto-dns yes
sudo nmcli connection up lab-wired
Profile activation can interrupt access. nmtui offers editing and activation menus for the same profiles. To restore DHCP, set ipv4.method auto, clear the manual addresses, gateway and DNS, and set ipv4.ignore-auto-dns no, then reactivate. Back up the original profile so restoration includes any previous special routes. Consult the nmcli manual for profile operations.
On a networkd-owned board without Netplan, the corresponding /etc/systemd/network/20-lab.network could contain:
[Match]
Name=eth0
[Network]
Address=192.168.50.20/24
Gateway=192.168.50.1
DNS=192.168.50.1
Networkd exports this DNS setting for resolver integration; it is not itself a general DNS resolver. With ifupdown, the equivalent addressing stanza in /etc/network/interfaces is:
auto eth0
iface eth0 inet static
address 192.168.50.20/24
gateway 192.168.50.1
DNS integration for ifupdown depends on additional hooks or a resolver manager; dns-nameservers is not universally effective without those components. Apply either alternative using that image's documented reload workflow from the console. Do not install all four examples together.
4Verify runtime and persistence
After applying, inspect addresses, routing and resolver status. Test the router, an allocated remote destination and a hostname separately; repeat after reboot. Raspberry Pi OS Bookworm normally uses NetworkManager; Yocto or Buildroot images may use networkd, ifupdown or BusyBox udhcpc, a DHCP client with integration scripts.
DNS and the application's lookup path
4 min readAn A record supplies IPv4, an AAAA record IPv6, and a CNAME record an alias. DNS records carry a time to live that permits caching. A name can resolve correctly while every resulting address is unreachable.
On glibc Linux, /etc/nsswitch.conf selects sources for name-service categories. Its hosts: line can include files, dns or resolve and conditional actions. files consults /etc/hosts; dns uses the libc DNS resolver; resolve integrates with systemd-resolved. Do not assume /etc/hosts is always first: inspect the installed order. Musl-based embedded systems do not implement glibc's pluggable Name Service Switch in the same way. See nsswitch.conf.
getent hosts board-lab
getent ahostsv4 example.com
cat /etc/hosts
grep '^hosts:' /etc/nsswitch.conf
ls -l /etc/resolv.conf
cat /etc/resolv.conf
resolvectl status
resolvectl query example.com
learner@embeddex:~/lab$ # Show the local hosts entry learner@embeddex:~/lab$ grep board-lab /etc/hosts 192.168.50.20 board-lab learner@embeddex:~/lab$ # Show which sources the hosts category consults learner@embeddex:~/lab$ grep '^hosts:' /etc/nsswitch.conf hosts: files dns learner@embeddex:~/lab$ # Follow the resolver configuration symlink learner@embeddex:~/lab$ ls -l /etc/resolv.conf -rw-r--r-- 1 root root 222 Nov 30 14:56 /etc/resolv.conf learner@embeddex:~/lab$ # Show the resolver configuration content learner@embeddex:~/lab$ cat /etc/resolv.conf # Generated by Docker Engine. # This file can be edited; Docker Engine will not make further changes once it # has been modified. nameserver 192.168.65.7 # Based on host file: '/etc/resolv.conf' (legacy) # Overrides: [] learner@embeddex:~/lab$
An intentionally local entry might be 192.168.50.20 board-lab in /etc/hosts. getent asks the configured name-service database; ahostsv4 requests IPv4 address information. Its results can therefore differ from direct DNS queries without either tool being broken.
Systemd-resolved manages name lookup, caching and per-link DNS routing. On a common Ubuntu setup, /etc/resolv.conf links to /run/systemd/resolve/stub-resolv.conf and names 127.0.0.53, a local DNS stub. That address is the local intermediary, not the upstream router. resolvectl status reveals upstream servers and link-specific settings. Other installations use different resolv.conf arrangements; inspect before changing anything. The resolved manual documents those modes.
Try it below: resolve etc/resolv.conf to watch the symlink being followed.
For direct DNS tests, install Ubuntu's dnsutils package if needed and use:
host example.com
dig example.com A
dig example.com AAAA
nslookup example.com
dig @192.168.50.1 example.com A
dig +tcp @192.168.50.1 example.com A
host is concise, dig exposes response details, and nslookup supports direct and interactive queries. These utilities query DNS rather than reproducing glibc's full name-service path. Without @server, dig normally uses resolv.conf, possibly reaching the local stub. With @server, it tests that particular server. DNS needs both UDP and TCP support; truncated replies and other cases require TCP. Inspect status, ANSWER, SERVER and timing instead of looking only for an address. NXDOMAIN means the queried name does not exist according to the answer; SERVFAIL means resolution failed, and timeout means no usable reply arrived.
Going deeperSplit DNS explains seemingly contradictory results
A private network may route one DNS suffix to its own server. A route-only domain such as ~example.internal directs matching queries without becoming a search suffix. Public resolvers generally cannot answer private names. A flat resolv.conf server list can discard link-aware behavior. Persist DNS through its owner; temporary resolvectl settings can be overwritten. WSL can generate resolver settings separately.
Key takeaways
- Administrative UP, carrier, an address and a usable route are separate facts.
- A prefix identifies a network; the longest matching route selects the destination path.
- Use one persistent configuration owner for each interface.
- getent follows the configured name-service path; dig asks a DNS server directly.
Reflect
- Explain to a colleague, in two sentences: identify interface operational states, IPv4 prefixes, routes and gateways from command output
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Official docsLinux kernel: operational states
- Official docsNetplan configuration examples
- Official docsNetworkManager nmcli manual
- Man pagesystemd-resolved.service
Official documentation first. Links checked when the lesson was published.