3
votes

I am using Centos 7, and trying to open ports 80 and 443.

Following instructions from centos 7 - open firewall port , RHEL7: How to get started with Firewalld, How to open http port 80 on Redhat 7 Linux using firewall-cmd and some others, I've got the following:

[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 ~]$

Even if I add ports 80/tcp and 443/tcp instead of adding the service, the result is the same, from other machine:

[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 ~]#

I have tried adding services and ports, with --permanent option, with and without sources, always reloading firewall after each change and even restarting firewalld service sometimes, but these ports are always closed.

Iptables is disabled.

2

2 Answers

5
votes

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

Worked for me on CentOS Linux release 7.1.1503 (Core)

1
votes

First install and start firewalld service

sudo yum install -y firewalld
sudo systemctl start firewalld 

Then open port 80 and 443 (and ssh 22 for remote shell if needed)

Use [--permanent] flag to keep changes after system reboot

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

Then reload firewalld service to activate new configuration

sudo systemctl reload firewalld