Disable Firewalld and Using IPTables
Disabling Firewalld and Using IPTables
Followling instruction is for centos 7. on centos 8 may be differnets.
systemctl stop firewalld
systemctl mask firewalld
systemctl disable firewalld
yum install -y iptables
yum install -y iptables-services
systemctl enable --now iptables
iptables -L
iptables -F
iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
iptables-save > /etc/sysconfig/iptables
Do automatic by run following command
curl -sS https://itmconsult.ir/linux/iptables/disable_firewalld.sh | sudo bash