De netwerkcommando's die ik het meest gebruik: adressen en routes met ip, instellingen met nmcli, DNS controleren, open poorten, en een WireGuard-VPN.

Spiekbriefje Linux-netwerken: ip, nmcli, DNS en WireGuard28 nov. 2026 PDF

πŸ€– Deze pagina is met AI vertaald uit het Engels. Lees het origineel in het Engels.

🌐 Spiekbriefje Linux-netwerken

ifconfig, route en netstat zijn verouderd; op huidige Linux-systemen gebruik je ip, ss en nmcli.


Adressen, verbindingen en routes: ip

ip -br a                     # all interfaces and addresses, one line each
ip a show dev eth0           # one interface, in detail
ip -br link                  # link state (UP/DOWN) and MAC addresses
ip r                         # routing table (IPv4)
ip -6 r                      # routing table (IPv6)
ip route get 1.1.1.1         # which interface and gateway are used for this address?
ip neigh                     # ARP / neighbour table: who is on the local network
ip -s link show dev eth0     # packet counters and errors

Tijdelijke wijzigingen (weg na een herstart):

sudo ip link set dev eth0 up
sudo ip addr add 192.0.2.10/24 dev eth0
sudo ip route add default via 192.0.2.1

Blijvende instellingen: nmcli (NetworkManager)

Fedora en Ubuntu Desktop gebruiken NetworkManager; nmcli is de commandoregelversie daarvan.

nmcli device status                     # all devices and their connections
nmcli connection show                   # all saved connections
nmcli connection show "Wired connection 1"   # every setting of one connection

# a fixed IP address
sudo nmcli connection modify "Wired connection 1" \
  ipv4.method manual ipv4.addresses 192.0.2.10/24 \
  ipv4.gateway 192.0.2.1 ipv4.dns "1.1.1.1 9.9.9.9"
sudo nmcli connection up "Wired connection 1"

# back to DHCP
sudo nmcli connection modify "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway ""

# Wi-Fi
nmcli device wifi list
nmcli device wifi connect "MyNetwork" --ask

Poorten en verbindingen: ss

sudo ss -tulpn               # which programs listen on which ports (TCP + UDP)
ss -tn state established     # open TCP connections

Meer in uitgaande verbindingen tonen.


DNS

resolvectl status            # which DNS servers are used, per interface
resolvectl query example.com
dig example.com +short       # from bind-utils (Fedora) / dnsutils (Debian/Ubuntu)
dig MX example.com +short
dig @9.9.9.9 example.com     # ask one specific DNS server

Bereikbaarheid

ping -c 4 192.0.2.1
tracepath example.com        # the route, no root needed
mtr example.com              # ping + traceroute live (package: mtr)
curl -sI https://example.com # does the web server answer? (headers only)
sudo ethtool eth0            # link speed and duplex of a network card

WireGuard-VPN

WireGuard is een kleine, snelle VPN die in de Linux-kernel zit. Elke kant heeft een sleutelpaar.

sudo apt install wireguard-tools    # or: sudo dnf install wireguard-tools
wg genkey | tee private.key | wg pubkey > public.key
chmod 600 private.key

Een configuratie voor de client, /etc/wireguard/wg0.conf:

[Interface]
PrivateKey = <contents of private.key>
Address = 10.8.0.2/24
DNS = 10.8.0.1

[Peer]
PublicKey = <public key of the server>
Endpoint = vpn.example.com:51820
AllowedIPs = 10.8.0.0/24, 192.168.1.0/24   # only these networks go through the VPN
PersistentKeepalive = 25
sudo wg-quick up wg0                     # connect
sudo wg show                             # status, last handshake, traffic
sudo wg-quick down wg0                   # disconnect
sudo systemctl enable --now wg-quick@wg0 # connect at every boot

Liever klikken? Importeer de configuratie in NetworkManager: sudo nmcli connection import type wireguard file /etc/wireguard/wg0.conf.

πŸ’‘ Met AllowedIPs = 0.0.0.0/0, ::/0 gaat al je verkeer door de VPN; met een lijst netwerken (zoals hierboven) alleen het verkeer naar die netwerken.