Difference between revisions of "Replace firewalld with iptables in CentOS"

From DevOps Notebook
(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...")
 
(No difference)

Latest revision as of 13:29, 8 October 2020

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