How to Open TCP and UDP Ports using firewall-cmd on CentOS/RedHat/Fedora

Shahriar Shovon

Supported OS

  • All

Categories

Share this post with your friends

This post is about how to open specific tcp and udp ports using the command firewall-cmd. So without further due, let's get started.

Opening TCP ports:

Let's say, I want to open the tcp ports 80 and 443 which are used by http and https protocol respectively. To do that, run the following commands, firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp

Opening UDP ports:

Let's say, I want to open the udp port 53, which is used by bind dns service. To do that, run the following command, firewall-cmd --permanent --add-port=53/udp

Reload the Configuration:

Now we have to reload firewall-cmd configurations. To do that, run the following command, firewall-cmd --reload

Verification:

To verify that the commands worked, let's view the current opened port list, firewall-cmd --list-ports 443/tcp 80/tcp 53/udp Tested on: CentOS 7