centos中iptables文件的添加方法
iptables文件的添加方法
- 任意执行一条iptables的防火墙配置规则指令
iptables -P OUTPUT ACCEPT
- 对iptables配置进行保存
service iptables save
- 重启 iptables服务器
service iptables restart
这样就能够在/etc/sysconfig目录下看到iptables文件了。
附件1 防火墙iptables文档的配置参考:
1 # Firewall configuration written by system-config-firewall 2 # Manual customization of this file is not recommended. 3 *filter 4 :INPUT ACCEPT [0:0] 5 :FORWARD ACCEPT [0:0] 6 :OUTPUT ACCEPT [0:0] 7 -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 8 -A INPUT -p icmp -j ACCEPT 9 -A INPUT -i lo -j ACCEPT 10 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 11 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT 12 -A INPUT -m state --state NEW -m tcp -p tcp --dport 8686 -j ACCEPT 13 -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 14 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 15 -A INPUT -j REJECT --reject-with icmp-host-prohibited 16 -A FORWARD -j REJECT --reject-with icmp-host-prohibited 17 COMMIT
附件2 centos防火墙开启、关闭、查看状态:
关闭虚拟机防火墙:
关闭命令: service iptables stop
永久关闭防火墙:chkconfig iptables off
两个命令同时运行,运行完成后查看防火墙关闭状态
service iptables status
1 关闭防火墙-----service iptables stop
2 启动防火墙-----service iptables start
3 重启防火墙-----service iptables restart
4 查看防火墙状态--service iptables status
5 永久关闭防火墙--chkconfig iptables off
6 永久关闭后启用--chkconfig iptables on
你的指尖,有着改变世界的力量!