How to open ports under linux

Take port 3306 of the mysql server as an example.

1. Open the port directly:
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

2. Permanently open a port
First , use vim to open the firewall configuration file:
vim /etc/sysconfig/iptables
Then, add it to the content of the iptables file The following:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Finally, after saving the configuration file, execute the following command to restart the firewall:
service iptables restart

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326344910&siteId=291194637