Bei Debian / Ubuntu kommt iptables-persistent zum Einsatz.
Debian / Ubuntu:
iptables-persistent befindet sich in den Standartrepositories und kann daher einfach mittelsapt-get install iptables-persistentinstalliert werden. Alternativ gehts auch manuell, .deb Datei + dpkg -i iptables-persistent_0.5.7_all.deb.
Die Regeln können jetzt ins Verzeichnis /etc/iptables/rules gespeichert werden und werden bei einem Neustart automatisch geladen. Im Verzeichnis befindet sich auch eine config Datei (iptables.conf) wo man einstellen kann, dass neue Regeln automatisch gespeichert werden sollen.
/etc/iptables$ cat iptables.confVorhandene Regeln werden mittels iptables-save gespeichert.
# Should new manually added rules from command line be saved on reboot? Assign to a value different that 0 if you want this enabled.
SAVE_NEW_RULES=0
iptables-save > /etc/iptables/rules
CentOS
In der Datei /etc/sysconfig/iptables-config kann festgelegt werden, wie mit den Regeln umgegangen werden soll. Die Konfiguration ist selbsterklärend. Für IPv6 Rules steht ip6tables.conf zur Verfügung. Zur veranschaulichung kopiere ich meine config Datei:sysconfig]# cat iptables-configDie Regeln befinden sich dann im File /etc/sysconfig/iptables bzw. /etc/sysconfig/ipv6iptables
# Load additional iptables modules (nat helpers)
# Default: -none-
# Space separated list of nat helpers (e.g. 'ip_nat_ftp ip_nat_irc'), which
# are loaded after the firewall rules are applied. Options for the helpers are
# stored in /etc/modprobe.conf.
IPTABLES_MODULES=""
# Unload modules on restart and stop
# Value: yes|no, default: yes
# This option has to be 'yes' to get to a sane state for a firewall
# restart or stop. Only set to 'no' if there are problems unloading netfilter
# modules.
IPTABLES_MODULES_UNLOAD="yes"
# Save current firewall rules on stop.
# Value: yes|no, default: no
# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets stopped
# (e.g. on system shutdown).
IPTABLES_SAVE_ON_STOP="yes"
# Save current firewall rules on restart.
# Value: yes|no, default: no
# Saves all firewall rules to /etc/sysconfig/iptables if firewall gets
# restarted.
IPTABLES_SAVE_ON_RESTART="yes"
# Save (and restore) rule and chain counter.
# Value: yes|no, default: no
# Save counters for rules and chains to /etc/sysconfig/iptables if
# 'service iptables save' is called or on stop or restart if SAVE_ON_STOP or
# SAVE_ON_RESTART is enabled.
IPTABLES_SAVE_COUNTER="yes"
# Numeric status output
# Value: yes|no, default: yes
# Print IP addresses and port numbers in numeric format in the status output.
IPTABLES_STATUS_NUMERIC="yes"
# Verbose status output
# Value: yes|no, default: yes
# Print info about the number of packets and bytes plus the "input-" and
# "outputdevice" in the status output.
IPTABLES_STATUS_VERBOSE="no"
# Status output with numbered lines
# Value: yes|no, default: yes
# Print a counter/number for every rule in the status output.
IPTABLES_STATUS_LINENUMBERS="yes"
kannst du deine ip tables rules posten?
AntwortenLöschensoll am besten alles blocken können.
die ich in google gefunden hab haben mein server zerschossen...
iptables von jemanden anderen bringen dir nichts. Du kannst nicht die Regeln von jemanden verwenden, der ganz andere Ports, Protokolle und Software verwendet als du.
AntwortenLöschenSinnvoller wäre es, wenn du schreibst, was du überhaupt brauchst. Und deine aktuelle iptable-ruleset solltest du auch posten, dann kann man sagen warum du ausgesperrt wurdest.
Wegen iptables hast du deinen Server bestimmt nicht zerschossen. Du hast dich maximal ausgesperrt.
Ja, ich hatte mich ausgesperrt. Habe es falsch formuliert.
AntwortenLöschenIch habe centos5 auf einem apache server. Das sind meine Regeln:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Bis jetzt habe ich nur den ssh port geändert, sonst ist alles standard.
Vielen Dank!
Hier die regeln:
AntwortenLöschen*mangle
:PREROUTING ACCEPT [69007:4644963]
:INPUT ACCEPT [69007:4644963]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [67020:16465039]
:POSTROUTING ACCEPT [67020:16465039]
COMMIT
# Completed on Sun Nov 17 13:43:40 2013
# Generated by iptables-save v1.3.5 on Sun Nov 17 13:43:40 2013
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [2:264]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i lo -j ACCEPT
COMMIT
Muss ich den port ändern? Mein ssh port ist ein anderer.
Ja, die Portnummer musst du auf den SSH Port anpassen.
AntwortenLöschen>OUTPUT ACCEPT [2:264]
Könntest du auch auf drop setzen. Dann aber eine output Regel hinzufügen für SSH.
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
könnte ebenfalls nützlich sein. Falls die Regeln so nicht funktionieren.