【问题标题】:Port 80 closed in Centos 7 with firewalld service在 Centos 7 中使用 firewalld 服务关闭端口 80
【发布时间】:2015-08-20 05:41:08
【问题描述】:

我正在使用 Centos 7,并尝试打开端口 80 和 443。

遵循来自 centos 7 - open firewall portRHEL7: How to get started with FirewalldHow to open http port 80 on Redhat 7 Linux using firewall-cmd 和其他一些,我有以下内容:

[ricardo@m42srv02 ~]$ firewall-cmd --list-all
  public (default, active)
  interfaces: enp0s3
  sources: 0.0.0.0/0
  services: dhcpv6-client http https ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

[ricardo@m42srv02 ~]$

即使我添加端口 80/tcp 和 443/tcp 而不是添加服务,结果是一样的,从其他机器:

[root@m42srv01 ~]# nmap -T4 -sV -p 1-444 192.168.1.12

Starting Nmap 5.51 ( http://nmap.org ) at 2015-06-04 04:33 CEST
Nmap scan report for 192.168.1.12
Host is up (0.017s latency).
Not shown: 441 filtered ports
PORT    STATE  SERVICE VERSION
22/tcp  open   ssh     OpenSSH 6.6.1 (protocol 2.0)
80/tcp  closed http
443/tcp closed https
MAC Address: 08:00:27:C1:8D:25 (Cadmus Computer Systems)

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 4.28 seconds
[root@m42srv01 ~]#

我尝试过添加服务和端口,使用 --permanent 选项,有无源,每次更改后总是重新加载防火墙,有时甚至重新启动 firewalld 服务,但这些端口总是关闭。

Iptables 被禁用。

【问题讨论】:

    标签: linux firewall centos7


    【解决方案1】:

    首先安装并启动firewalld服务

    sudo yum install -y firewalld
    sudo systemctl start firewalld 
    

    然后打开端口 80 和 443(如果需要,打开 ssh 22 用于远程 shell)

    使用 [--permanent] 标志在系统重启后保留更改

    sudo firewall-cmd --zone=public --permanent --add-port=80/tcp
    sudo firewall-cmd --zone=public --permanent --add-port=443/tcp
    sudo firewall-cmd --zone=public --permanent --add-port=22/tcp
    

    然后重新加载firewalld服务以激活新配置

    sudo systemctl reload firewalld
    

    【讨论】:

      【解决方案2】:

      试试:firewall-cmd --zone=public --add-port=80/tcp --permanent

      在 CentOS Linux 版本 7.1.1503(核心)上为我工作

      【讨论】:

      • 注意你还需要运行firewall-cmd --reload
      • 或重新加载firewalld服务sudo systemctl reload firewalld
      猜你喜欢
      • 1970-01-01
      • 2011-08-15
      • 2015-12-18
      • 2012-09-09
      • 2013-12-08
      • 2014-09-03
      • 2017-04-13
      • 2013-02-19
      相关资源
      最近更新 更多