English Chinese (Simplified)
$ firewall-cmd --list-ports
$ sudo firewall-cmd --remove-port=port-number/port-type
$ sudo firewall-cmd --runtime-to-permanent
Closing a port
Closing a port using the command line
List all allowed ports:
Make the new settings persistent:
Remove the port from the allowed ports to close it for the incoming traffic:
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.
To close a port, remove it from the list of allowed ports:
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.