linux 防火墙开启80端口报错 和 80开启
2016-11-20 18:18
295 查看
今天客户那边有台服务器同一个局域网中都无法访问,排除lamp环境问题,发现是服务器中的防火墙没有开启80端口。于是去网上搜索了一下,在脚本之家看到一种添加代码的方法
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙)
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允许3306端口通过防火墙)
按照这种方法测试,发现重启防火墙的时候,回报这两行错误。
[root@localhost ~]# /etc/init.d/iptables restart
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
iptables:应用防火墙规则:Bad argument `–-state'
Error occurred at line: 11
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[失败]
发现这种方法并不好使,于是尝试另外一种,通过命令去添加端口的方法。
[root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@centos httpd]# /etc/rc.d/init.d/iptables save
[root@centos httpd]# /etc/init.d/iptables restart
这样就搞定了,查看效果
[root@centos httpd]# /etc/init.d/iptables status
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允许80端口通过防火墙)
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(允许3306端口通过防火墙)
按照这种方法测试,发现重启防火墙的时候,回报这两行错误。
[root@localhost ~]# /etc/init.d/iptables restart
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
iptables:应用防火墙规则:Bad argument `–-state'
Error occurred at line: 11
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[失败]
发现这种方法并不好使,于是尝试另外一种,通过命令去添加端口的方法。
[root@centos httpd]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@centos httpd]# /etc/rc.d/init.d/iptables save
[root@centos httpd]# /etc/init.d/iptables restart
这样就搞定了,查看效果
[root@centos httpd]# /etc/init.d/iptables status
相关文章推荐
- linux 配置防火墙,开启80端口、3306端口
- Linux中在防火墙中开启80端口的例子
- Linux配置防火墙 开启80端口的方法
- Linux Centos firewall 防火墙 开启 80 端口配置案例
- linux 防火墙开启80端口永久保存
- Linux配置防火墙 开启80端口、3306端口的方法
- Linux下在防火墙中开启80端口、3306端口的方法
- Linux配置防火墙,开启80端口、3306端口
- Linux配置防火墙 开启80端口、3306端口的方法
- linux开启防火墙,开放80端口,开放mysql的3306端口,开放svn的3609端口,开放tomcat的8080端口。
- Linux配置防火墙 开启80端口、3306端口的方法
- linux 配置防火墙,开启80端口、3306端口
- Linux配置防火墙,开启80端口、3306端口
- Linux配置防火墙 开启80端口的方法
- Linux下防火墙,开启80、3306等服务端口
- Linux配置防火墙,开启80端口、3306端口
- Linux中在防火墙中开启80端口的例子
- Linux中在防火墙中开启80端口的例子
- linux防火墙开启80端口
- Linux中在防火墙中开启80端口的例子