[Solution] Linux virtual machine open port number, virtual machine centos7 open port

Original link

1. First check whether the firewall is enabled and the open ports:

systemctl status firewalld.service (check whether the firewall is on or off)

sudo firewall-cmd --list-all (you can view the opening of the port)

firewall-cmd --zone=public --query-port=3306/tcp (check the opening of a port, return yes or no)

2. Use the following commands to enable or disable the firewall of the virtual machine

systemctl stop firewalld.service (stop firewall)

systemctl start firewalld.service (open firewall)

disable firewalld.service (turn off boot from start)

3. Next, open the http 8080(80) port with the following command:

sudo firewall-cmd --add-service=http --permanent (allow http service)

sudo firewall-cmd --add-port=8080/tcp --permanent (open port 8080, if it is mysql, open port 3306)

Note: –permanent at the end of the command means that it will be valid for a long time. If this sentence is not added, the port that was just opened will become invalid after restarting.

4. Finally restart the firewall:

sudo firewall-cmd --reload (check port opening)

sudo firewall-cmd --list-all

Discover services: http service appears, ports: port 8080/80 appears:

5. The local browser accesses the virtual machine ip address successfully

In this way, I successfully opened the port number of my virtual machine, and can access the client through the browser. In this way, I can also open 8081, but I have not succeeded in accessing through the browser, so this paragraph is not finished. …

Guess you like

Origin blog.csdn.net/NEFUT/article/details/130957591