nftables ist der Nachfolger von iptables und hat eine deutlich einfachere Syntax. Es ist in allen modernen Distributionen standardmässig installiert.
Doku
Migration nach nftables
Alle iptables rules rauswerfen:
iptables -F
Wenn die Migration abgeschlossen ist, kann man das iptables Kernel Modul ganz raus werfen
thommie@locutus:~> lsmod | grep ipta
iptable_nat 12288 3
nf_nat 65536 5 ip6table_nat,xt_nat,nft_chain_nat,iptable_nat,xt_MASQUERADE
rmmod iptable_nat
Das Modul nf_table hat die gleiche Funktion. Hier wird die Migration beschreiben:
https://tuxcare.com/de/blog/iptables-vs-nftables/
iptables-save > /some/file schreibt man alle aktuellen Regeln in eine Datei.
# Generated by iptables-save v1.8.11 (nf_tables) on Fri Jan 9 07:38:49 2026
*nat
:PREROUTING ACCEPT [220:13224]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [159:16951]
-A PREROUTING -i eth0 -p udp -m udp --dport 10000 -j DNAT --to-destination 148.251.43.62:10000
-A POSTROUTING -s 148.251.43.62/32 -p udp -m udp --sport 10000 -j SNAT --to-source 10.10.10.52:10000
COMMIT
# Completed on Fri Jan 9 07:38:49 2026
Mit iptables-translate kann man einzelne iptables rules in nftables Regeln übersetzen.
iptables-translate -I PREROUTING -i eth0 -t nat -p udp --dport 10000 -j DNAT --to-destination 148.251.43.62:10000
nftables Übersetzung
nft 'insert rule ip nat PREROUTING iifname "eth0" udp dport 10000 counter dnat to 148.251.43.62:10000'
iptables-translate -I POSTROUTING -t nat -p udp --sport 10000 -s 148.251.43.62 -j SNAT --to-source 10.10.10.52:10000
nftables Übersetzung
nft 'insert rule ip nat POSTROUTING ip saddr 148.251.43.62 udp sport 10000 counter snat to 10.10.10.52:10000'
iptables Port Forwarding
Alle Regeln anzeigen mit iptables -nvL
Z.B. für nat:
root@kakariki /etc/network # iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 23M packets, 1309M bytes)
pkts bytes target prot opt in out source destination
2493 119K DNAT tcp -- vmbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:9443 to:10.10.10.14:9443
325 36774 DNAT udp -- vmbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:10000 to:10.10.10.52:10000
0 0 DNAT udp -- vmbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:10000 to:10.10.10.52:10000
Chain INPUT (policy ACCEPT 445K packets, 22M bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 182K packets, 12M bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 22M packets, 1286M bytes)
pkts bytes target prot opt in out source destination
209K 13M MASQUERADE all -- * vmbr0 10.10.10.0/24 0.0.0.0/0
0 0 SNAT tcp -- * * 10.10.10.14 0.0.0.0/0 tcp spt:9443 to:148.251.43.46:9443
0 0 SNAT udp -- * * 10.10.10.52 0.0.0.0/0 udp spt:10000 to:148.251.43.62:10000
0 0 SNAT udp -- * * 10.10.10.52 0.0.0.0/0 udp spt:10000 to:148.251.43.62:10000
iptables Port Forwarding
post-up iptables -t nat -A PREROUTING -i vmbr0 -p udp --dport 10000 -j DNAT --to-destination 10.10.10.52:10000
post-up iptables -t nat -A POSTROUTING -p udp --sport 10000 -s 10.10.10.52 -j SNAT --to-source 148.251.43.62:10000
Tcpdump
Doku
https://www.cyberciti.biz/faq/tcpdump-capture-record-protocols-port/
Live-Traffic auf tcp oder udp
tcpdump -i eth0 -A udp
tcpdump -i eth0 -A tcp
Traffic auf einer bestimmten Schnittstelle auf einem bestimmten Port
tcpdump -i vmbr0 -nn port 1194
tcpdump -i vmbr1 -nn port 1194
nftables Befehle und Syntax
Aktuelle Regeln auflisten
sudo nft list ruleset