yum -y install ipset
ipset create blacklist hash:net hashsize 4096 maxelem 100000 timeout 300
ipset create whitelist hash:net hashsize 4096 maxelem 1000000
ipset add blacklist 10.10.10.0/24 timeout 60
ipset del blacklist 10.10.10.0/24
ipset list blacklist
iptabels -A INPUT -m set --match-set blacklist src -j DROP
ipset save blacklist -f blacklist.txt
ipset destroy blacklist
ipset flush blacklist
ipset restore -f blacklist.txt
iptables -A INPUT -p tcp -m set --match-set blacklist src -m multiport --dports 443,80 -j DROP
yum install -y iptables
yum install iptables-services
systemctl start iptables
systemctl enable iptables
systemctl stop firewalld
systemctl disable firewalld
iptables -F
# 清空所有自定义规则
iptables -X
# 所有计数器归0
iptables -Z
# 允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
# 允许ping
# iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
# iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT
#允许接受本机请求之后的返回数据 RELATED,是为FTP设置的
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#其他入站一律丢弃
iptables -P INPUT DROP
#所有出站一律绿灯
iptables -P OUTPUT ACCEPT
# 所有转发一律丢弃
#iptables -P FORWARD DROP
原文:https://www.cnblogs.com/ray-mmss/p/14465302.html