linux:iptables
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| linux:iptables [2020-11-26 12:32:14] – manfred | linux:iptables [2022-03-23 10:27:59] (aktuell) – [ALLE Regeln flushen] manfred | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== iptables ====== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | > apt install iptables-persistent | ||
| + | > cat / | ||
| + | > cat / | ||
| + | > iptables -A ... | ||
| + | > iptables-save > / | ||
| + | |||
| + | |||
| + | ===== Regeln anzeigen ===== | ||
| + | |||
| + | |||
| + | ==== Filter ==== | ||
| + | |||
| + | # iptables -L -t filter | ||
| + | |||
| + | oder einfach so: | ||
| + | # iptables -L -n | ||
| + | |||
| + | ausführlicher so: | ||
| + | # iptables -L -n -v | ||
| + | |||
| + | |||
| + | ==== NAT ==== | ||
| + | |||
| + | # iptables -L -t nat | ||
| + | |||
| + | um lange DNS-Abfragen zu vermeiden, besser so: | ||
| + | # iptables -L -n -t nat | ||
| + | |||
| + | ausführlicher so: | ||
| + | # iptables -L -n -v -t nat | ||
| + | |||
| + | |||
| + | ===== Regeln Boot-fest machen ===== | ||
| + | |||
| + | # iptables-save > / | ||
| + | | ||
| + | # echo "# | ||
| + | # echo " | ||
| + | # chmod 0755 / | ||
| + | |||
| + | |||
| + | ===== bestimmte Regeln löschen ===== | ||
| + | |||
| + | |||
| + | ==== nach Aufruf ==== | ||
| + | |||
| + | Die Regeln, die so reingeschrieben werden (man achte auf das '' | ||
| + | # iptables -t nat -A PREROUTING -d 192.186.0.65 -j DNAT --to-destination 192.186.0.101 | ||
| + | # iptables -t nat -A POSTROUTING -s 192.186.0.101 -j SNAT --to-source 192.186.0.65 | ||
| + | |||
| + | Regeln anzeigen (man achte auf das '' | ||
| + | # iptables -L -n -t nat | ||
| + | |||
| + | ...können so wieder entfernt werden (man achte auf das '' | ||
| + | # iptables -t nat -D PREROUTING -d 192.186.0.65 -j DNAT --to-destination 192.186.0.101 | ||
| + | # iptables -t nat -D POSTROUTING -s 192.186.0.101 -j SNAT --to-source 192.186.0.65 | ||
| + | |||
| + | |||
| + | ==== nach Nummer ==== | ||
| + | |||
| + | # iptables -L -n -t nat --line-numbers | ||
| + | Chain PREROUTING (policy ACCEPT) | ||
| + | num target | ||
| + | 1 DNAT | ||
| + | | ||
| + | Chain INPUT (policy ACCEPT) | ||
| + | num target | ||
| + | | ||
| + | Chain OUTPUT (policy ACCEPT) | ||
| + | num target | ||
| + | | ||
| + | Chain POSTROUTING (policy ACCEPT) | ||
| + | num target | ||
| + | 1 SNAT | ||
| + | | ||
| + | | ||
| + | # iptables -t nat -D PREROUTING 1 | ||
| + | | ||
| + | # iptables -t nat -D POSTROUTING 1 | ||
| + | |||
| + | |||
| + | ===== ALLE Regeln flushen ===== | ||
| + | |||
| + | # iptables -F -t nat | ||
| + | | ||
| + | # iptables -P INPUT DROP | ||
| + | # iptables -F INPUT | ||
| + | # iptables -P OUTPUT DROP | ||
| + | # iptables -F OUTPUT | ||
| + | # iptables -P FORWARD DROP | ||
| + | # iptables -F FORWARD | ||
| + | |||
