How to open port in built-in firewall on the RedHat machine?
To check the current state of the RedHat built-in firewall, you need to call the below command:
sudo firewall-cmd --list-all
You should get something like this:
[[email protected] ~]$ sudo firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
You can also check iptables
with sudo iptables-save | grep <port_number>
command.
To add new rule you need to call the below commands (remembering to update the port number):
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
The result should be like below:
[[email protected] ~]$ sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[[email protected] ~]$ sudo firewall-cmd --reload
success
When you will check the firewall state, the new port should be visible:
[[email protected] ~]$ sudo firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: cockpit dhcpv6-client ssh
ports: 8080/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
Newsletter
Thank you for visiting my website. I hope you enjoyed content which I prepared and learned something valuable from it. If you want to be informed about my next entries or occasionally get a message with a collection of some interesting links, please subscribe to my newsletter. I will be extremely pleased if you do this and join my community!