menu

How To Open A Port In CentOS 7 With Fiewalld

  • date_range Dec. 02, 2019 - Monday info
    sort label

Open Specific Port

Opening a port in firewalld is fairly straightforward, in the below example we allow traffic in from any source IP address to TCP port 100. First we modify the persistent configuration, then we reload firewall-cmd to load this change into the running configuration.

[root@centos7 ~]# firewall-cmd --permanent --add-port=100/tcp
success
[root@centos7 ~]# firewall-cmd --reload
success

If the –permanent flag is not specified, this will only change the running configuration but will not be saved.

We can check the ports that are opened in the current default zone with ‘–list-ports’.

[root@centos7 ~]# firewall-cmd --list-ports
100/tcp
As expected we see that TCP port 100 is open.

Should we wish to remove a port, we can use ‘--remove-port=’ instead.

We can also open a range of ports in the same way.

[root@centos7 ~]# firewall-cmd --permanent --add-port=200-300/tcp
success

Reference

» Check this link



KF

Comments