Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Sv translation
languagede

CentOS 7

On Auf CentOS 7 , wird firewall-cmd is used to maintain the firewall.

List All Rules

zur Wartung der Firewall verwendet.

Alle Regeln auflisten

firewall-cmd --list-all

Allow a port

Einen Port zulassen

Dieses Beispiel erlaubt einen TCP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" (öffentlichen) ZoneThis example allows a TCP port through the firewall, for all network interfaces in the "public" zone:
firewall-cmd --zone=public --add-port=3306/tcp --permanent


This example allows a UDP port through the firewall, for all network interfaces in the Dieses Beispiel erlaubt einen UDP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" zoneZone:
firewall-cmd --zone=public --add-port=20202/udp --permanent

Delete a rule

Löschen einer Regel

firewall-cmd --zone=public --remove-port=3306/tcp --permanent

Reload the firewall

Die Firewall neu laden

Dadurch werden die Portänderungen aktivThis makes the port changes active:

firewall-cmd --reload
If port changes are specified without the


Wenn Port-Änderungen ohne das Kennzeichen --permanent

flag, they will be active, but not permanent. The following command makes them

angegeben werden, sind sie aktiv, aber nicht dauerhaft. Der folgende Befehl macht sie permanent:

firewall-cmd

--runtime-to-permanent

CentOS 6

On Auf CentOS 6 , iptables is used to maintain the firewall.

Caution: iptables is cryptic and sometimes rather stupid. Especially: it will add multiple rules for the same port, and does not check if the port is already open.

List All Rules

wird iptables zur Wartung der Firewall verwendet.

Vorsicht: iptables ist kryptisch und manchmal etwas dumm. Besonders: es fügt mehrere Regeln für den gleichen Port hinzu und prüft nicht, ob der Port bereits offen ist..

Alle Regeln auflisten

iptables -L -n

The -n option causes the ports to be listed numerically.

Die Option -n bewirkt, dass die Ports numerisch aufgelistet werden.


AlternativAlternatively:

iptables-save > iptables_rules
less iptables_rules

This method is particularly useful for cleaning up duplicated rules.

Allow a port

Diese Methode ist besonders nützlich, um doppelte Regeln zu bereinigen.

Einen Port zulassen

Dieses Beispiel lässt einen TCP-Port durch die Firewall zuThis example allows a TCP port through the firewall:
iptables -I INPUT 4 -p tcp -m tcp --dport 3306 -j ACCEPT
service iptables save


This example allows a UDP port through the firewall, for all network interfaces in the Dieses Beispiel erlaubt einen UDP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" zoneZone:
iptables -I INPUT 4 -p tcp -m udp --dport 20202 -j ACCEPT
service iptables save

Reload the firewall

Firewall neu laden

Dadurch werden die Portänderungen dauerhaftThis makes the port changes permanent:

service iptables save

Delete a rule

The simplest way to delete rules in iptables, is to save and restore the configuration:

Löschen einer Regel

Der einfachste Weg, Regeln in iptables zu löschen, ist das Speichern und Wiederherstellen der Konfiguration:


Speichern Sie zunächst die RegelnFirst, save the rules:

iptables-save > iptables_rules


Now edit the rulesBearbeiten Sie nun die Regeln:

vi iptables_rules


Now restore the rules, with the changes made, and make them permanentStellen Sie nun die Regeln mit den vorgenommenen Änderungen wieder her und machen Sie sie dauerhaft:

iptables-restore < iptables_rules
service iptables save