Home  >  Article  >  Operation and Maintenance  >  What is the command to open a port in Linux?

What is the command to open a port in Linux?

WBOY
WBOYOriginal
2022-07-21 14:19:3554808browse

In Linux, the command to open a port is "firewall-cmd --zone=public --add-port=port/communication protocol --permanent"; the "--zone" in this command indicates the role Domain, "--permanent" means that after opening the port, it will take effect permanently. After using this command to open the specified port, you need to restart the firewall to make it effective.

What is the command to open a port in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the command to open a port in Linux

The command to open a port in Linux is

firewall-cmd --zone=public --add-port=端口/通讯协议 --permanent

It should be noted that we need to restart the firewall after opening the specified port.

Examples are as follows:

1. Open the firewall

    systemctl start firewalld

2. Open the specified port

      firewall-cmd --zone=public --add-port=1935/tcp --permanent

Command meaning:

  • --zone #scope

  • --add-port=1935/tcp #Add port, the format is: port/communication protocol

  • --permanent #Effective permanently, without this parameter it will be invalid after restarting

3. Restart the firewall

      firewall-cmd --reload

4. Check the port number

netstat -ntlp   //查看当前所有tcp端口·
netstat -ntulp |grep 8888   //查看所有1935端口使用情况·

Recommended learning: Linux video tutorial

The above is the detailed content of What is the command to open a port in Linux?. 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