linux学习笔记三:防火墙设置

请注意:centOS7和7之前的版本在防火墙设置上不同,只有正确的设置防火墙才能实现window下访问linux中的web应用。

centOS6添加端口:

vi /ets/sysconfig/iptables

在-A INPUT -m state--state NEW -m tcp -p tcp --dport 22 -j ACCEPT下面添加类似的配置

如-A INPUT -m state--state NEW -m tcp -p tcp --dport 8080 -j ACCEPT    #允许外部访问8080端口

最后重启防火墙:

service iptables restart/start/stop

centOS7添加端口:

firewall-cmd --zone=public --add-port=8080/tcp --permanent        #永久添加8080端口

firewall-cmd --reload                      #重新加载策略配置,以使新配置生效

最后设置防火墙重启后生效:

chkconfig iptables on

猜你喜欢

转载自www.cnblogs.com/x-jingxin/p/9032139.html