Sv translation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CentOS 7On CentOS 7, firewall-cmd is used to maintain the firewall. List All Rules
Allow a portThis example allows a TCP port through the firewall, for all network interfaces in the "public" zone:
This example allows a UDP port through the firewall, for all network interfaces in the "public" zone:
Delete a rule
Reload the firewallThis makes the port changes active:
If port changes are specified without the --permanent flag, they will be active, but not permanent. The following command makes them permanent:
CentOS 6On 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
The -n option causes the ports to be listed numerically. Alternatively:
This method is particularly useful for cleaning up duplicated rules. Allow a portThis example allows a TCP port through the firewall:
This example allows a UDP port through the firewall, for all network interfaces in the "public" zone:
Reload the firewallThis makes the port changes permanent:
Delete a ruleThe simplest way to delete rules in iptables, is to save and restore the configuration:
First, save the rules:
Now edit the rules:
Now restore the rules, with the changes made, and make them permanent:
|
Sv translation | ||
---|---|---|
| ||
CentOS 7Auf CentOS 7 wird firewall-cmd zur Wartung der Firewall verwendet. Alle Regeln auflistenfirewall-cmd --list-all Einen Port zulassenDieses Beispiel erlaubt einen TCP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" (öffentlichen) Zone: Dieses Beispiel erlaubt einen UDP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" Zone: Löschen einer Regelfirewall-cmd --zone=public --remove-port=3306/tcp --permanent Die Firewall neu ladenDadurch werden die Portänderungen aktiv: firewall-cmd --reload Wenn Port-Änderungen ohne das Kennzeichen --permanent angegeben werden, sind sie aktiv, aber nicht dauerhaft. Der folgende Befehl macht sie permanent: firewall-cmd --runtime-to-permanent CentOS 6Auf CentOS 6 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 auflisteniptables -L -n Die Option -n bewirkt, dass die Ports numerisch aufgelistet werden. Alternativ: iptables-save > iptables_rules less iptables_rules Diese Methode ist besonders nützlich, um doppelte Regeln zu bereinigen. Einen Port zulassenDieses Beispiel lässt einen TCP-Port durch die Firewall zu: Dieses Beispiel erlaubt einen UDP-Port durch die Firewall für alle Netzwerkschnittstellen in der "public" Zone: Firewall neu ladenDadurch werden die Portänderungen dauerhaft: service iptables save Löschen einer RegelDer einfachste Weg, Regeln in iptables zu löschen, ist das Speichern und Wiederherstellen der Konfiguration: Speichern Sie zunächst die Regeln: iptables-save > iptables_rules Bearbeiten Sie nun die Regeln: vi iptables_rules Stellen Sie nun die Regeln mit den vorgenommenen Änderungen wieder her und machen Sie sie dauerhaft: iptables-restore < iptables_rules |