阿里云配置iptables防火墙

天远科技  发表于:2015-12-17  分类:操作系统相关  阅读(3796)  赞同22

iptables 查看防火墙配置情况使用命令 iptables -L -n

使用 service iptables status可以查看防火墙状态

使用命令 service iptables start 开启防火墙

iptables -P INPUT ACCEPT   先允许INPUT

iptables -F   //清空默认的所有规则

iptables -X    //清空自定义规则

iptables -Z    //计数清零


iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A INPUT -j ACCEPT -p tcp --dport 22        //增加22端口
iptables -A INPUT -j ACCEPT -p tcp --dport 3306    //增加3306端口
iptables -A INPUT -j ACCEPT -p tcp --dport 53
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT    //本机对外请求相当于OUTPUT,对于返回数据包必须接收啊,这相当于INPUT了
iptables -A INPUT -p icmp --icmp-type 8 -s 10.9.1.0/22 -j ACCEPT        //对某网段的IP允许ping
iptables -A INPUT -p icmp --icmp-type 8 -s 172.31.2.0/26 -j ACCEPT    
iptables -A INPUT -p icmp --icmp-type 8 -j DROP    //过滤以上没定义的ping

iptables -P INPUT DROP    //过滤以上没定义的规则


执行 service iptables save保存防火墙配置

也可以执行chkconfig iptables on 默认服务器启动是开启防火墙

博文分类

线

在线联系
点击这里给我发消息
点击这里给我发消息
关注我们