redhat linux/CentOS 6/7 如何关闭防火墙? |
您所在的位置:网站首页 › 红帽linux防火墙关闭端口 › redhat linux/CentOS 6/7 如何关闭防火墙? |
redhat linux/CentOS 6/7 如何关闭防火墙?关闭防火墙iptables的具体命令如下: 临时性的完全关闭防火墙,可以不重启机器(但是重启服务器后iptables防火墙服务会自动随系统启动): 123#/etc/init.d/iptables status ## 查看防火墙状态#/etc/init.d/iptable stop ## 本次关闭防火墙#/etc/init.d/iptable restart ## 重启防火墙永久性关闭防火墙(关闭后,iptables服务不会再随机器自动启动): 方案1 1#chkconfig --level 35 iptables off ##方案2 开启: 1chkconfig iptables on关闭: 1chkconfig iptables off对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。 redhat linux/CentOS防火墙打开TCP端口的命令举例如下: 123#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT #/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT #/etc/rc.d/init.d/iptables save redhat linux/CentOS防火墙iptables介绍iptables是基于内核的防火墙,功能非常强大,iptables内置了filter,nat和mangle三张表。 filter负责过滤数据包,包括的规则链有,input,output和forward; nat则涉及到网络地址转换,包括的规则链有,prerouting,postrouting和output; mangle表则主要应用在修改数据包内容上,用来做流量整形的,默认的规则链有:INPUT,OUTPUT,NAT,POSTROUTING,PREROUTING; input匹配目的IP是本机的数据包,forward匹配流经本机的数据包,prerouting用来修改目的地址用来做DNAT,postrouting用来修改源地址用来做SNAT。 CentOS防火墙iptables关闭之后的作用?CentOS防火墙iptables关闭之后系统将会容易受到攻击,一些系统默认开启的端口如果不一一关闭,将会容易受到黑客攻击,因此建议默认开启iptables防火墙,并且在防火墙中配置仅仅开启需要使用的端口。 CentOS 防火墙不关行不行?但是在特定的情况下,如果我们某些应用程序使用了一些端口被防火墙封了,那么这时候有两种选择:要么关闭防火墙,要么将某些应用程序需要的端口在防火墙的规则中进行配置。因此,CentOS 防火墙完全可以不用关闭! CentOS 防火墙iptables的一些基本操作及举例iptables -L 列出iptables规则 iptables -F 清除iptables内置规则 iptables -X 清除iptables自定义规则 清除原有规则 iptables -F 清除预设表filter中的所有规则链的规则 iptables -X 清除预设表filter中使用者自定链中的规则 添加规则. 如果开启了web服务器,OUTPUT设置成DROP的话, 1iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT ,其他同理.如果做了WEB服务器,开启80端口. 1iptables -A INPUT -p tcp --dport 80 -j ACCEPT如果做了邮件服务器,开启25,110端口. 12iptables -A INPUT -p tcp --dport 110 -j ACCEPTiptables -A INPUT -p tcp --dport 25 -j ACCEPT如果做了FTP服务器,开启21端口 12iptables -A INPUT -p tcp --dport 21 -j ACCEPTiptables -A INPUT -p tcp --dport 20 -j ACCEPT如果做了DNS服务器,开启53端口 1iptables -A INPUT -p tcp --dport 53 -j ACCEPT目的地址转换,映射内部地址 12iptables -t nat -A PREROUTING -i ppp0 -p tcp --dprot 81 -j DNAT --to 192.168.0.2:80iptables -t nat -A PREROUTING -i ppp0 -p tcp --dprot 81 -j DNAT --to 192.168.0.1-192.168.0.10源地址转换,隐藏内部地址 12iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to 1.1.1.1iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to 1.1.1.1-1.1.1.10地址伪装,动态ip的NAT 1iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE多端口匹配,用以一次匹配多个端口 1iptables -A INPUT -p tcp -m muliport --dport s 21,22,25,80,110 -j ACCEPT |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |