赞
踩
(1). 查看本机关于IPTABLES的设置情况
[root@localhost etc]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
(2). 保存iptables文件
iptables文件在新安装的系统中是不存在的,执行以下操作会生成该文件。
[root@localhost /]#service iptables save
iptables: Saving firewall rules to/etc/sysconfig/iptables:[ OK ]
(3). 打开/etc/sysconfig/iptable文件添加规则
# Generated by iptables-save v1.4.7 onTue May 5 15:16:19 2015
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2209:357963]
-AINPUT -p udp -m udp --dport 17001 -j ACCEPT
-AINPUT -p tcp -m tcp --dport 18000 -j ACCEPT
-AINPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -m state --stateRELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -mtcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-withicmp-host-prohibited
-A FORWARD -j REJECT --reject-withicmp-host-prohibited
COMMIT
# Completed on Tue May 5 15:16:19 2015
(4). 重启防火墙
得把防火墙重起一下,才能起作用.
[root@tp ~]# service iptables restart
注意:以上操作大部分需要root权限。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。