To open a port using firewalld, you can use the following command:
sudo firewall-cmd --zone=public --add-port=PORT_NUMBER/tcp --permanent
Replace PORT_NUMBER with the actual port number you want to open. For example, to open port 8080, you would use:
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
After adding the port, reload the firewall to apply the changes:
sudo firewall-cmd --reload
Note
- The
--permanentoption makes the change persistent across reboots. - If you want to open a UDP port, replace
tcpwithudp.
Further Learning
For more details, you can check the firewalld documentation or explore related labs on LabEx.
