且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Centos 开放80端口

更新时间:2022-09-16 17:46:38

一、添加规则

#/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 

再查看是否已经有了: 
[root@vcentos ~]# /etc/init.d/iptables status 
Table: filter 
Chain INPUT (policy ACCEPT) 
num target prot opt source destination 
1 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:80 
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 
3 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0 

Chain FORWARD (policy ACCEPT) 
num target prot opt source destination 
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0


二.重启电脑。

1.CentOS操作系统防火墙默认已经开放了80和22端口

2.这里应该也可以不重启计算机:
#/etc/init.d/iptables restart
防火墙的关闭,关闭其服务即可:

3.查看防火墙信息:
#/etc/init.d/iptables status

4.关闭防火墙服务:
#/etc/init.d/iptables stop

三.永久关闭防火墙

我们也可以永久的关闭防火墙,但是我不建议大家这样做.永久关闭防火墙可以这样:
#chkconfig –level 35 iptables off
也可以直接修改
/etc/sysconfig/iptables
添加一条
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT


本文转自郝峰波博客园博客,原文链接:http://www.cnblogs.com/fengbohello/p/4647011.html,如需转载请自行联系原作者