Enable the linux system firewall and allow other ports.

Published: 2019-12-26

Our elastic cloud host does not restrict ports externally by default. If the port is not accessible externally after the service is running, you can refer to this tutorial to allow the corresponding port in the firewall.

1. WDCP system port opening:

(1) Version 3.2

After logging in to the wdcp panel, click "Security Management" — "Firewall Settings" — "Quick Add", fill in the port as shown in the figure (the protocol defaults to tcp), and save to allow it.

(2) Version 2.5

After logging in to wdcp, click "Security Management" — "Firewall (iptables)" — Add Rule

As shown in the figure, generally just fill in the port to be allowed and click OK.



2. 宝塔面板 port opening:

After logging in to the panel, click "Security"; in the firewall, select "Allow Port", then fill in the port number. The remark is optional. Click Allow. As shown in the figure below, this is allowing port 3306 of the mysql database.



3. Clean system port opening:

(1) Use a script to allow ports (supports pre-installed panels or clean versions of centos6, 7 systems and ubuntu systems)

a. Log in to the server using ssh

b. Paste the following script and press Enter to run it

wget -O portctl.sh http://downinfo.myhostadmin.net/vps/portctl.sh && bash portctl.sh && rm -rf portctl.sh

Enter the port to be allowed, press Enter, then enter the protocol. If it is the tcp protocol, just press Enter to allow it. If it is a port range, enter the range ports separated by an English colon. Deleting allowed ports is supported.

(2) Command-line operation (requires logging in to the server via ssh):

centos6:

iptables -I INPUT -p protocol -m protocol --dport port -j ACCEPT
iptables-save > /etc/sysconfig/iptables
service iptables restart

centos7 (only one of firewalld and iptables can be used):

a. iptables

iptables -I INPUT -p protocol -m protocol --dport port -j ACCEPT
iptables-save > /etc/sysconfig/iptables
systemctl restart iptables

b. firewall

firewall-cmd --permanent --zone=public --add-port=port/protocol
firewall-cmd --reload

ubuntu:

Our company does not enable the firewall by default on this system. If needed, you can use the above script to allow ports or enable the system ufw firewall to perform operations.

ufw enable   (start the firewall)
ufw allow port/protocol
ufw reload

If the port is still inaccessible after following this tutorial, please check whether the relevant application or service inside the server is listening. You can use netstat -nptl to check. If you cannot solve it independently, you can submit a ticket, and our technical staff will assist with handling it.