norboten · cheat sheet

Resolves here, listens there, routes until Tuesday — cheat sheet

networking
# names, the way applications resolve them
grep '^hosts' /etc/nsswitch.conf          # files dns myhostname — the order
getent hosts NAME ; getent ahosts NAME    # through NSS: /etc/hosts, then DNS, …
dig NAME ; dig +short NAME                # DNS only — exit 0 even for NXDOMAIN
dig NAME | grep status:                   # NOERROR / NXDOMAIN / SERVFAIL
dig @192.168.5.3 NAME                     # ask one specific server
host NAME                                 # DNS only, exit 1 on NXDOMAIN

# who configures DNS
head -1 /etc/resolv.conf                  # "Generated by NetworkManager" = do not edit
systemctl is-active systemd-resolved
nmcli connection modify "$con" ipv4.dns "A B" ipv4.ignore-auto-dns yes ipv4.dns-search DOMAIN
nmcli device reapply eth0

# listening
ss -lntp                                  # local address: 127.0.0.1 = loopback only, 0.0.0.0 = all IPv4
ss -lnup                                  # UDP
curl -m 2 http://CLIENT_FACING_ADDRESS:PORT/    # not localhost
# curl exit: 6 cannot resolve, 7 refused, 28 timeout

# routes
ip route ; ip -6 route
ip route get DEST                         # gateway, interface and source the kernel will use
ip route add NET via GW                   # runtime only (gone at reboot)
nmcli connection modify "$con" +ipv4.routes "NET GW" ; nmcli device reapply eth0
# NetworkManager's routes show "proto static metric N"; hand-added ones do not

# addresses
ip -4 -br addr ; nmcli -g GENERAL.CONNECTION device show eth0