English Portuguese (Portugal)
Closing a port
When an open port is no longer needed, close that port in firewalld. It is highly recommended to close all unnecessary ports as soon as they are not used because leaving a port open represents a security risk.
Closing a port using the command line
To close a port, remove it from the list of allowed ports:
List all allowed ports:
$ firewall-cmd --list-ports
This command will only give you a list of ports that have been opened as ports. You will not be able to see any open ports that have been opened as a service. Therefore, you should consider using the --list-all option instead of --list-ports.
Remove the port from the allowed ports to close it for the incoming traffic:
$ sudo firewall-cmd --remove-port=port-number/port-type
Make the new settings persistent:
$ sudo firewall-cmd --runtime-to-permanent