Replace firewalld with iptables in CentOS

From DevOps Notebook
Revision as of 13:29, 8 October 2020 by MilosZ (talk | contribs) (Created page with "Stop and disable firewalld <pre> # systemctl stop firewalld # systemctl disable firewalld </pre> Install and enable iptables service <pre> # yum install iptables-services # s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Stop and disable firewalld

# systemctl stop firewalld
# systemctl disable firewalld

Install and enable iptables service

# yum install iptables-services
# systemctl enable iptables

Create simple iptables to allow port 22 by editing '`'/etc/sysconfig/iptables

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-port-unreachable
COMMIT

Start iptables and verify that rules have been applied

# systemctl start iptables
# iptables -nL