linux设置白名单关闭防火墙使用iptables

创建iptables文件类似

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [79:6432]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [24:1644]
-N whitelist
-A whitelist -s IP地址  -j ACCEPT


-A INPUT -p udp -m udp --dport 23 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 23 -j ACCEPT 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
#-A RH-Firewall-l-INPUT -p tcp -m tcp --dport 11211 -j ACCEPT
COMMIT

禁用防火墙,安装iptables服务并启用

sudo systemctl stop firewalld.servicesudo systemctl disable firewalld.service

sudo yum install iptables-services 
sudo systemctl enable iptables 
sudo systemctl enable ip6tables 
sudo systemctl start iptables 
sudo systemctl start ip6tables

你可能感兴趣的:(linux设置白名单关闭防火墙使用iptables)