Home>Article>Operation and Maintenance> How to open ports with firewall-cmd command

How to open ports with firewall-cmd command

藏色散人
藏色散人 Original
2023-01-04 15:11:19 8465browse

How to open the port with firewall-cmd command: 1. Open the terminal command window; 2. Open it by executing the "firewall-cmd --zone=public --add-port=8888/tcp --permanent" command Just specify the port.

How to open ports with firewall-cmd command

The operating environment of this tutorial: Centos7 system, Dell G3 computer.

How to open the port with the firewall-cmd command?

Centos7 Use the firewall-cmd command to open and view port openings

1. Open ports

firewall-cmd --zone=public --add-port=8888/tcp --permanent # 开放5672端口 firewall-cmd --zone=public --remove-port=8888/tcp --permanent #关闭5672端口 firewall-cmd --reload # 配置立即生效

2. View all open ports on the firewall

firewall-cmd --zone=public --list-ports

3. Turn off the firewall

If you don’t want to control the port, just turn off the system firewall. Everything will work, but the security is not strong, so it is not recommended.

systemctl stop firewalld.service

4. Check the firewall status

firewall-cmd --state

5. Check the listening port

netstat -lnpt

PS: centos7 does not have the netstat command by default. You need to install the net-tools tool, yum install - y net-tools

6. Check which process the port is occupied

netstat -lnpt |grep 8888

7. View the detailed information of the process

ps 8888

8. Terminate the process

kill -9 6832

Recommended study: "Linux Video Tutorial"

The above is the detailed content of How to open ports with firewall-cmd command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn