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

What is the command to open a port in Linux?

WBOY
Release: 2022-07-21 14:19:35
Original
54818 people have browsed it

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
Copy after login

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
Copy after login

2. Open the specified port

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

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
Copy after login

4. Check the port number

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template