Menu
User

DropVPS Team

Writer: John hens

How to open tcp port in red hat?

How to open tcp port in red hat?

Publication Date

07/27/2025

Category

Articles

Reading Time

2 Min

Table of Contents

By default, Red Hat Enterprise Linux uses firewalld to manage network access. If you want to allow access to a specific TCP port, you need to add a rule through the firewall and apply the changes.

Step 1: Check firewall status

Before adding any rules, verify that firewalld is running:

sudo systemctl status firewalld

If it’s inactive, you can start it using sudo systemctl start firewalld.

Step 2: Open the TCP port

Use the following command to permanently open a TCP port like 8080:

sudo firewall-cmd --permanent --add-port=8080/tcp

You can replace 8080 with any port you need for your application or service.

Step 3: Reload firewall rules

Once you’ve added the rule, reload the firewall so changes take effect:

sudo firewall-cmd --reload

This applies all pending changes without needing a system reboot.

Step 4: Confirm the port is open

You can list all open ports and confirm your rule is active:

sudo firewall-cmd --list-ports

If the port appears in the list (e.g., 8080/tcp), it’s successfully open.

Step 5: Test external access

Make sure a service is listening on the opened port, then test the connection from another machine using tools like telnet, nc, or a browser if it’s HTTP-based. Example:

telnet your-server-ip 8080

Or using curl:

curl http://your-server-ip:8080

If nothing is listening on the port, the firewall will allow traffic, but the system won’t respond.

If you no longer want to expose the port, you can remove it and reload the firewall:

sudo firewall-cmd --permanent --remove-port=8080/tcp && sudo firewall-cmd --reload

This will block external access to that port again.

Linux VPS
U
Loading...

Related Posts