Bootstrap FreeKB - Firewalld - firewall-cmd - allow or deny a port
Firewalld - firewall-cmd - allow or deny a port

Updated:   |  Firewalld articles

If you are not familar with firewalld and the firewall-cmd, check out our Getting Started article.

The --add-port=port_number/protocol option can be used to allow connections to a port number. This is typically used when a protocol is not using the default port associated with the protocol, such as when HTTP is using 8080. --add-service is used when the protocol is using it's common port, such as when HTTP is using port 80.

firewall-cmd --add-port=12345/tcp --permanent
firewall-cmd --reload


Or --remove-port=port_number/protocol to remove a port.

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


The --check-config command can be used to ensure there are no configuration errors.

~]$ firewall-cmd --check-config


firewall-cmd --list-all will show the allowed ports.

~]# firewall-cmd --list-all
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  ports: 12345/tcp
  masquerade: no
  rich rules:


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 47e626 in the box below so that we can be sure you are a human.