Wiki source for LinuxIptables


Show raw source

=====iptables=====

Banning2002, S. 424

====Kommandos====

iptables
iptables-save


====Auflisten====

Regeln auflisten
%%(bash)
iptables -L
%%


====Verwerfen====

%%(bash)
iptables -A INPUT -s ! 192.168.0.1/24 -p tcp --destination-port 22 -j DROP
iptables -A INPUT -s ! 192.168.0.1/24 -p tcp --destination-port 443 -j DROP
%%

icmp Pakete die von 192.168.0.3 kommen blocken
%%(bash)
iptables -A INPUT -s 192.168.0.3 -p icmp -j DROP
%%

Regel wieder aufheben
%%(bash)
iptables -D INPUT -s 192.168.0.3 -p icmp -j DROP
%%

Alle pakete von 192.168.1.2 verwerfen
%%(bash)
iptables -A INPUT -s 192.168.1.2 -j DROP
%%

Alle pakete von xyz.domain.org verwerfen
%%(bash)
iptables -A INPUT -s xyz.domain.org -j DROP
%%

Port 25 für tcp sperren
%%(bash)
iptables -A INPUT -s 0.0.0.0/0 -p tcp --destination-port smtp -j DROP
iptables -A INPUT -s 0.0.0.0/0 -p tcp --destination-port 9 -j DROP
iptables -A INPUT -s 0.0.0.0/0 -p tcp --destination-port 13 -j DROP
%%

Nur das Netz 192.168.0.1/24 für SSH zulassen
%%(bash)
iptables -A INPUT -s 192.168.0.1/24 -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -s 0.0.0.0/0 -p tcp --destination-port 22 -j DROP
%%

alternativ
%%(bash)
iptables -A INPUT -s ! 192.168.0.1/24 -p tcp --destination-port 22 -j DROP
%%

Port 445 für Rechner 192.168.0.5 sperren
%%(bash)
iptables -A INPUT -s 192.168.0.5 -p tcp --destination-port 445 -j DROP
%%


192.168.0.0/24 <-- ROUTER --> 192.168.1.0/24

Port 25 des Rechners 192.168.1.2 über den Router schützen
%%(bash)
iptables -A FORWARD -d 192.168.1.2 -p tcp --destination-port 25 -j DROP
%%

Kein Routing(Forwarding) für Rechner 192.168.1.2
%%(bash)
iptables -A FORWARD -d 192.168.1.2 -j DROP
%%


====Regeln aufheben====

Inpunt-Regel Nr 1 aufheben (geht nur wenn dies die erste ...)
%%(bash)
iptables -D INPUT 1
%%

Alle Regeln einer Kette löschen
%%(bash)
iptables -F INPUT
%%

====Policy====

Policy ändern
%%(bash)
iptables -P FORWARD ACCEPT
%%

oder
%%(bash)
iptables -P FORWARD DENY
%%


====Einfügen====

Eine regel an der ersten stelle beim INPUT-Filter einfügen
%%(bash)
iptables -I INPUT 1 ......
%%

Nur eingehende tcp-Verbindungen unterbinden
%%(bash)
iptables -A INPUT -p tcp --syn -j DROP
%%


====Loggen====

Pakete loggen
%%(bash)
iptables -A FORWARD -d 192.168.1.2 -p tcp --syn -j LOG --log-prefix "IBM Connection request: "
%%



Netzwerkpakete protokollieren
http://www.linux-fuer-alle.de/doc_show.php?docid=148&catid=11

====Limits====

%%
-m limit --limit 200/minute --limit-burst 200
%%

%%
-m connlimit --connlimit-above 15 --connlimit-mask 32
%%

----
Siehe auch {{backlinks}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki