Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to turn on Firewall and specific Port in liunx

Shulou Source: shulou.com Published: 2022-06-02 07:51:41 10月03日 Update

This article mainly explains "liunx how to open firewall and specific port". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "liunx how to open firewall and specific port".

Enable firewall service

In the past, for convenience, the firewalls were turned off, because now the projects are more important and afraid of being attacked, so for the sake of security, we now need to turn on the firewall. Next, we will introduce the steps.

1, first check the firewall status:

Firewall-cmd-state

2. Turn on the firewall

Start firewall:

Systemctl start firewalld.service

Set self-boot:

Systemctl enable firewalld.service

3. Restart the firewall:

Systemctl restart firewalld.service

4, check whether the firewall status is turned on:

Firewall-cmd-state

As shown in the picture, it has been opened.

5. Check whether the firewall is set to boot successfully:

Systemctl is-enabled firewalld.service;echo $?

Open a specific port

Here, take opening port 80 as an example

Command:

Open port command: firewall-cmd-- zone=public-- add-port=80/tcp-- permanent

Restart the firewall: systemctl restart firewalld.service

Meaning of the command:

-- zone # scope

-- add-port=80/tcp # add port in the format: Port / communication protocol

-- permanent # is in effect forever. Without this parameter, it will expire after restart.

As shown in the figure, you can see that the port has been opened successfully:

If you are not assured, you can use the command:

Netstat-ntlp

Or: firewall-cmd-- list-ports

Thank you for reading, the above is the content of "how to open the firewall and specific ports of liunx". After the study of this article, I believe you have a deeper understanding of how to open the firewall and specific ports of liunx, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Firewall fire protection port command learning success content status such as figure importance security next function parameter can pass meaning security that is train of thought situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Apple Microsoft OPPO Reno