Part II · Your system
19. Network
hub
Your network interfaces, their addresses, where traffic goes, and how names become addresses.
On your machine
$ atfq network docker0 down · virtual · MAC 02:42:5c:11:aa:01 172.17.0.1/16 enp0s31f6 down · MAC 54:e1:ad:12:34:56 lo unknown · loopback 127.0.0.1/8, ::1/128 wlp0s20f3 up · wireless · MAC 8c:c6:81:2a:10:7f 192.168.1.23/24, fe80::8ec6:81ff:fe2a:107f/64 Route default via 192.168.1.1 on wlp0s20f3
An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.
Commands
ip -br addr- each interface and its addresses, one line each
ip route- where packets go, default gateway included
ping -c 3 example.com- is a host reachable, and how fast
ss -tulpn- ports open for connections 19.1
resolvectl status- DNS servers in use, per interface 19.2
nmcli device- NetworkManager's view, Wi-Fi included
curl -I https://example.com- test an HTTPS connection, headers only
Paths
/etc/hosts- names resolved without DNS
/etc/resolv.conf- DNS servers the system resolver asks
/sys/class/net/- one folder per interface: state, MAC, speed
Cards
- 19.1Who listens on which portA program that accepts connections listens on a port: 22 for SSH, 443 for HTTPS.
- 19.2DNS resolutionPrograms ask the system resolver to turn a name into an address. It tries the sources on the hosts: line of /etc/nsswitch.conf, in order.
- 19.3Interfaces and routesAn interface is a network connection point: enp3s0 (cable), wlp2s0 (Wi-Fi), lo (the machine itself).
- 19.4nftables vs iptables vs ufwThe kernel does the filtering (netfilter). iptables, nftables, ufw and firewalld are ways to write its rules.
Also about this
- 6.1Network layers: OSI and TCP/IPA network is built in layers, each using the one below: link (Ethernet, Wi-Fi), network (IP), transport (TCP, UDP), application (HTTP, DNS, SSH).
- 6.2What happens when you open a websiteDNS: the name becomes an IP address (19.2).
- 6.3IP addresses, subnets and NATAn IPv4 address is 32 bits, written 192.168.1.23. /24 means the first 24 bits name the network and the rest the machine.
- 6.4TCP, UDP and connectionsTCP gives a reliable, ordered stream: it numbers the bytes, waits for acknowledgements and sends again what was lost.
- 6.5Ethernet, MAC addresses and ARPOn a local network, frames travel from MAC address to MAC address: 48-bit hardware addresses such as f4:92:bf:0e:21:7a.