标签:
[root@tp ~]#iptables -L -n 查看防火墙规则
[root@tp ~]# iptables -F 清除预设表filter中的所有规则链的规则
[root@tp ~]# iptables -X 清除预设表filter中使用者自定链中的规则
设置链的默认策略。一般有两种方法。
首先允许所有的包,然后再禁止有危险的包通过放火墙。
[root@tp ~]#iptables -P INPUT ACCEPT
[root@tp ~]#iptables -P OUTPUT ACCEPT
[root@tp ~]#iptables -P FORWARD ACCEPT
首先禁止所有的包,然后根据需要的服务允许特定的包通过防火墙。
[root@tp ~]#iptables -P INPUT DROP
[root@tp ~]#iptables -P OUTPUT DROP
[root@tp ~]#iptables -P FORWARD DROP
这样就可以写到/etc/sysconfig/iptables文件里了.写入后记得把防火墙重启才能起作用.
[root@tp ~]# /etc/rc.d/init.d/iptables save
[root@tp ~]#/etc/init.d/iptables restart
INPUT链和OUTPU链的默认规则是DROP,所以我们就写需要ACCETP(通过)的链
开通远程SSH登陆
[root@tp ~]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
[root@tp ~]# iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
开通icmp包通过(ping命令)
[root@tp ~]# iptables -A OUTPUT -p icmp -j ACCEPT
[root@tp ~]# iptables -A INPUT -p icmp -j ACCEPT
允许192.168.0.3的机器进行SSH连接
[root@tp ~]# iptables -A INPUT -s 192.168.0.3 -p tcp --dport 22 -j ACCEPT
标签:
原文地址:http://www.cnblogs.com/zoulongbin/p/5737497.html