FirewallD |CentOS 7 [SOLVED]

I would like know which the best practice for add port web to FirewallD in CentOS 7.

When you add Apache/HTTPD

Way 1:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https

Way 2:

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

2 Replies

Both methods are functionally equivalent, as add-service simply adds the default port for the service. Whichever one you'd prefer is the one I'd recommend using. In most cases, using add-service is suggested for readability and ease of use, but if you ever need to use a non-standard port for a service you'll nee to use add-port instead.

Thanks so much for you answared!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct