---
title: "CentOS 防火墙开启80端口"
author: "ljl961890233bear"
date: "2015-08-03T17:58:44Z"
tags: []
categories: ["操作系统"]
slug: "centos-80"
draft: false
lastmod: "2015-08-03T17:58:44Z"
id: 2232527
url: "https://btbear.iteye.com/blog/2232527"
---

CentOS 防火墙开启80端口

网上搜索了很多都没解决问题，下面是正确方法：

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

如果上面的步骤还没好的话，可能是这个iptables文件使用的是包含调用。

一般的在/etc/sysconfig/iptables这个路径上

打开这个文件修改手动添加就行了。

注意需要重启服务哦：执行service iptabels save 与 service iptables restart

端口查看方法:

\[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