iptables防火墙规则设置

来源:互联网 发布:在虚拟机上安mac 编辑:程序博客网 时间:2024/05/12 01:45

#注:Linux7 默认启用的是firewalld.service,要启用iptables,需要关闭firewalld.service

systemctl stop firewalld.service;systemctl disable firewalld.service

yum install iptables -y;systemctl start iptables.service;systemctl enable iptables.service


规则设置:

规则1:控制单个IP的最大并发连接数,允许单个IP的最大连接数为10

vi /etc/sysconfig/iptables      添加下面内容(要在COMMIT之前)

-I INPUT -p tcp --dport 80 -m connlimit --connlimit-above 10 -j REJECT

保存后,重启服务systemctl restart iptables.service


规则2:限制特定IP才能访问服务器的端口

vi /etc/sysconfig/iptables      添加下面内容(要在COMMIT之前)

-P INPUT DROP

-A INPUT -s IP地址 -p tcp --dport 端口号 -j ACCEPT


1 0
原创粉丝点击