
add-forward-port : to specify port number where request needs to forward 10. ~]# firewall-cmd -add-forward-port=port=8080:proto=tcp:toport=7000 success Here we are telling to forward all the incoming requests from Port 8080 to Port 7000. You can also enable port forwarding through your firewall by using -add-forward-port option as shown below.

~]# firewall-cmd -permanent -remove-port=3306/tcp success 9. If you want to permanently remove mysql port from firewall then you need to use -permanent option with -remove-port option to implement that functionality. Remove MySQL Port Permanently from firewalld ~]# firewall-cmd -remove-port=3306/tcp success Offcourse this change will be a runtime change and will get reset after a reboot. If you want to temporarily remove mysql port access from firewall then you can simply run firewall-cmd -remove-port=3306/tcp command to achieve that. add-service : to add a specific service 7. ~]# firewall-cmd -zone=public -add-service=smtp success Sometimes instead of allowing SMTP port through firewall you can also add service name and allow SMTP using below command. ~]# systemctl restart firewalldĪfter restarting the service you can again check the list of ports using firewall-cmd -list-ports command. Now you need to restart firewalld services using systemctl restart firewalld command. You need to restart your firewalld service as well to reflect the changes in the list of ports.

Simply after adding the port in firewall rules you won't see in the list. Reflect Changes in Firewalld for Recently Added Port ~]# firewall-cmd -zone=public -permanent -add-port=6990-7000/tcp success 5.

You can also open a range of port from 6990-7000 through the firewall using below command. Allow Range of Port 6990-7000 Permanently on Public Zone If no zone specified, then it will allow for default zone. add-port : to allow a port for the mentioned zone. permanent : this option will allow the rules to be persistent even after reboot If you want to allow Port 7000 permanently on public zone, then you need to use firewall-cmd -zone=public -permanent -add-port=7000/tcp command as shown ~]# firewall-cmd -zone=public -permanent -add-port=7000/tcp success Allow Port 7000 Permanently on Public Zone If zone is not mentioned, it will show for default zone. list-ports : to list all the ports available for a zone. It will show all the ports currently allowed through firewall. To check all the active ports you need to use firewall-cmd -list-ports command as shown below. Services: dhcpv6-client mdns samba-client ssh If you change the zone then that zone will show active.

If you notice the output carefully you can see a default public zone showing active. Here you can see a list of all system defined zones. You can check all the zones and its associated rules by using firewall-cmd -list-all-zones command as shown below. You can check 10 Useful Firewall CMD Examples on RedHat/CentOS 7 to know more about firewalld services. Here, we will go through number of different methods which can be used to allow ports through firewall. Both the options are extensively used in Production environment in many of the Organizations as per their requirement. It allows port and services to be opened during runtime and also allows it to be persistent after reboot. firewall-cmd is the command line tool used to manage firewalld rules. In this article, I will take you through Popular firewalld Examples to open a port on RedHat/CentOS 7.
