centos6.5添加白名单如下:
在防火墙 配置文件中加入白名单 ip
-A INPUT -s 183.136.133.0/24 -j ACCEPT //保存重启iptables服务,则只有该段可以访问
批量添加 参考:http://www.ithov.com/linux/135727.shtml
查看iptables规则是否生效
[root@ithov ~]# iptables -nL
# Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 8080 -j ACCEPT -A INPUT -p tcp --dport 8091 -j ACCEPT -A INPUT -p tcp --dport 3306 -j ACCEPT -A INPUT -s 121.199.130.108 -p tcp --dport 15000 -j ACCEPT //只允许该公网ip访问该端口 -A INPUT -s 10.0.0.0/8 -p tcp --dport 15000 -j ACCEPT //允许该网段访问该端口 -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT