OpenVZ: Node iptables fügt keine Regeln an

OpenVZ: Node iptables fügt keine Regeln an

Ich möchte einen Satz von Regeln für iptables innerhalb eines Knotens erstellen, aber es scheint, dass iptables nicht alle Regeln anhängt oder mich irgendwie jedes Mal rauswirft, wenn ich das folgende Skript ausführe (ich verwende diesen Satz von Regeln auf anderen Servern und er funktioniert einwandfrei):

# Allow connections that are already connected to your server
iptables -A INPUT -i venet0 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow connections to SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT

# Allowing connections to HTTP/HTTPS
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT

# Allow icmp input but limit it to 10/sec
iptables -A INPUT -p icmp -m limit --limit 10/second -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT

# Allow all incoming traffic from local
iptables -A INPUT -i lo -j ACCEPT

# Changing the default policy for INPUT chain
iptables -A INPUT -j DROP

Das Problem, das ich gefunden habe (nehme ich an), ist, dass die letzte Zeile (DROP anything) als eine solche interpretiert wird und der Server mich deshalb rauswirft.

Ich habe die Konfiguration für vz bereits geändert:

IPTABLES_MODULES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state xt_state ip_conntrack"

Wir sind für jede Hilfe dankbar.

Danke.

Antwort1

Ich habe mehr Probleme mit OpenVZ und der Verwendung von „ESTABLISHED,RELATED“ gesehen. Leider konnte ich nicht herausfinden, wie ich die OpenVZ-Installationen reparieren kann, die aus irgendeinem Grund keine statusbehafteten iptables in Containern zulassen.

Aber müssen die IPTable-Regeln, die Sie haben, wirklich zustandsbehaftet sein? Ich denke, Folgendes funktioniert genauso gut:

# Allow connections to SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Allowing connections to HTTP/HTTPS
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

# Allow icmp input but limit it to 10/sec
iptables -A INPUT -p icmp -m limit --limit 10/second -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT

# Allow all incoming traffic from local
iptables -A INPUT -i lo -j ACCEPT

# Changing the default policy for INPUT chain
iptables -A INPUT -j DROP

verwandte Informationen