Preface
I bought an Alibaba Cloud server and developed some small programs on it. I often need to open the port. Write a blog to record the steps.
Operating environment
- Purchased Alibaba Cloud server
Start
1. Use the command lsb_release -a to view the Linux release version
Mine is centos7.
2. Enter the command firewall-cmd --state to view the status of the firewall.
3. If the previous step is closed, enter the command:
systemctl start firewalld.service
turns on the firewall.
4. Open port 8080 and enter the command:
firewall-cmd --zone=public --add-port=8080/tcp --permanent
Let us explain the last command:
--zone=public: indicates that the scope is public;
--add-port=8080/tcp: Add the port 8080 of the tcp protocol;
--permanent: permanently effective, if there is no this parameter, it can only maintain the current service life cycle, and it will become invalid after restart;
5. Enter the command to restart the firewall;
systemctl restart firewalld.service
6. Enter the command to reload the configuration;
firewall-cmd --reload
7. Open the official website of Aliyun https://www.aliyun.com/ , and find the console in the upper right corner after logging in
Find the ECS you purchased,
click Manage,
click the security group of this instance , click Configure Rules to
add security group rules,
fill in the example and click OK.