Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


lpi2:iptables

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
lpi2:iptables [2013/12/13 16:23] – [Debian] ingo_wichmannlpi2:iptables [2019/12/19 17:19] (aktuell) – [Links] dirk_streubel
Zeile 1: Zeile 1:
 +====== iptables beobachten ======
 +  watch -d iptables -nvL --line-numbers
 +
 +  * -L = List (auflisten)
 +  * -n = no DNS-lookup
 +  * -v = verbose (gesprächig)
 +  * --line-numbers = Regeln Nummerieren (einzelne Regeln können anhand der Nummer z.B. gelöscht werden)
 +
 +====== iptables Regeln zurücksetzen ======
 +===== filter =====
 +  iptables -P INPUT ACCEPT
 +  iptables -P OUTPUT ACCEPT
 +  iptables -P FORWARD ACCEPT
 +  iptables -F
 +  iptables -X
 +===== nat =====
 +  iptables -t nat -F
 +  iptables -t nat -X
 +
 +====== iptables Syntax ======
 +^ table     ^ command ^ chain  ^ rule-specification             ^^^ target         ^^ 
 +| -t filter | -A | INPUT       | -s |           |                 | -j | ACCEPT     |
 +| :::       | -C | OUTPUT      | -d |           |                 | :::| DROP       |
 +| :::       | -D | FORWARD     | -i |           |                 | :::| REJECT     |
 +| :::       | -I | :::         | -o |           |                 | :::| LOG        |
 +| :::       | -R | :::         |    |           |                 | :::| :::        | 
 +| -t nat    | -L | PREROUTING  | -p | udp       | ''%%--dport%%''     | -j | SNAT       |
 +| :::       | -S | OUTPUT      | :::| :::       | ''%%--sport%%''     | :::| DNAT       |
 +| :::       | -F | POSTROUTING | :::| tcp       | ''%%--dport%%''     | :::| MASQUERADE |
 +| :::       | -Z | :::         | :::| :::       | ''%%--sport%%''     | :::| :::        |
 +| -t mangle | -N | PREROUTING  | :::| icmp      | ''%%--icmp-type%%'' | :::| :::        |
 +| :::       | -X | OUTPUT      |    |           |                 | :::| :::        |
 +| :::       | -P | INPUT       | -m | conntrack | ''%%--ctstate%%''       | :::| :::        |
 +| :::       | -E | POSTROUTING |    |           |                 | :::| :::        |
 +(( inspiriert von:
 +{{:iptables.jpg?direct&900|}}
 +))
 +
 ====== Einbindung von iptables in den Bootvorgang ====== ====== Einbindung von iptables in den Bootvorgang ======
-===== CentOS =====+===== CentOS (bis 6) ===== 
 +Paket: iptables-services 
   /etc/init.d/iptables save   /etc/init.d/iptables save
 speichert die aktuell aktiven iptables-Regeln in der Datei ''/etc/sysconfig/iptables''. Beim Booten werden sie hier wieder ausgelesen.  speichert die aktuell aktiven iptables-Regeln in der Datei ''/etc/sysconfig/iptables''. Beim Booten werden sie hier wieder ausgelesen. 
 +
 +===== CentOS (ab 7) =====
 +wie SuSE, oder ''firewalld'' nutzen
 +
  
 ===== SuSE ===== ===== SuSE =====
Zeile 75: Zeile 119:
   update-rc.d iptables start 40 S . stop 89 0 6 .   update-rc.d iptables start 40 S . stop 89 0 6 .
  
-| -t | filter | -A | INPUT       | -s |      |             | +Alternativ: 
-|    | :::    | -C | OUTPUT      | -d |      |             | +''/etc/network/interfaces'' : 
-|    | :::    | -D | FORWARD     | -i |      |             | +<file> 
-|    | :::    | -I |             | -o |      |             | +auto eth0 
-| -t | nat    | -R | PREROUTING  |    |      |             | +iface eth0 inet dhcp 
-|    | :::    | -L | OUTPUT      | -p | udp  | --dport     | +  up sh -c 'iptables-restore < /etc/iptables' 
-|    | :::    | -S | POSTROUTING |    | :::  | --sport     | +</file>
-|    | :::    | -F |             |    | tcp  | --dport     | +
-| -t | mangle | -Z | PREROUTING  |    | :::  | --sport     | +
-|    | :::    | -N | OUTPUT      | -m | icmp | --icmp-type | +
-|    | :::    | -X | INPUT       |    |      |             | +
-|    | :::    | -P | POSTROUTING |    |      |             | +
-|    | :::    | -E |             |    |      |             | +
- +
- +
-====== iptables Syntax ====== +
-{{:iptables.jpg?direct&900|}} +
- +
-====== iptables beobachten ====== +
-  watch -d iptables -L -n -v --line-numbers +
- +
-  * -L = List (auflisten) +
-  * -n = no DNS-lookup +
-  * -v = verbose (gesprächig) +
-  * --line-numbers = Regeln Nummerieren (einzelne Regeln können anhand der Nummer z.B. gelöscht werden) +
- +
-====== iptables filter-Regeln komplett zurücksetzen ====== +
-  iptables -P INPUT ACCEPT +
-  iptables -P OUTPUT ACCEPT +
-  iptables -P FORWARD ACCEPT +
-  iptables -F +
-  iptables -X +
-  iptables -t nat -F +
-  iptables -t nat -X+
 ====== Einfacher Paketfilter mit NAT ====== ====== Einfacher Paketfilter mit NAT ======
  
Zeile 177: Zeile 194:
   * http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO.html   * http://www.netfilter.org/documentation/HOWTO/netfilter-extensions-HOWTO.html
   * http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html   * http://www.frozentux.net/iptables-tutorial/iptables-tutorial.html
 +  * https://gist.github.com/mcastelino/c38e71eb0809d1427a6650d843c42ac2
 +
  
-===== iptables und dhcp ===== 
-  * http://www.faveve.uni-stuttgart.de/it/auth/dhcp.php 
  
 ===== iptables und ssh ===== ===== iptables und ssh =====
   * http://www.debian-administration.org/articles/187 , aber: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332231   * http://www.debian-administration.org/articles/187 , aber: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332231
 +
lpi2/iptables.1386951829.txt.gz · Zuletzt geändert: 2013/12/13 16:23 von ingo_wichmann