How to Add Exception Ports in Linux Firewall

Below we use CentOS as an example:

Step 1: Access the CentOS system locally or via SSH, then run the command “/sbin/iptables -I INPUT -p tcp –dport 3306 -j ACCEPT” and confirm (using port 3306 as an example here).

Step 2: Use the command “/etc/init.d/iptables status” to view the firewall exception port you just added.

Step 3: This is not complete yet. You must also execute the /etc/rc.d/init.d/iptables save command and confirm.

Step 4: Execute the service iptables restart command and confirm. When you see an OK prompt, it means the firewall has restarted successfully, and all exception ports added in Step 1 will now take effect.

Leave a Comment

Your email address will not be published.