Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to set up Firewall in linux

Shulou Source: shulou.com Published: 2022-06-02 10:27:53 09月12日 Update

This article will explain in detail how to set up a firewall in linux. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Check the status of the firewall: systemctl status firewalld

Firewall systemctl start firewalld.service needs to be turned on

Firewall-cmd-- zone=public-- list-ports # # View open ports

two。 Add port 8484 to whitelist execution

Firewall-cmd-permanent-zone=public-add-port=8484/tcp

Prompt success to indicate success

Command meaning

-- zone # scope

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

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

3. Restart the firewall: you need to restart the firewall after it has been successfully added

Firewall-cmd-reload

4. test

Other common commands:

Firewall-cmd-- state # # check the firewall status, whether it is running

Firewall-cmd-- reload # # reload the configuration, for example, after adding rules, you need to execute this command

Firewall-cmd-- get-zones # # list supported zone

Firewall-cmd-- get-services # # lists the supported services, and the services in the list are released

Firewall-cmd-- query-service ftp # # check whether the ftp service is supported, and return yes or no

Firewall-cmd-add-service=ftp # # temporarily open ftp service

Firewall-cmd-add-service=ftp-permanent # # permanently open ftp service

Firewall-cmd-remove-service=ftp-permanent # # permanently remove ftp service

Firewall-cmd-add-port=80/tcp-permanent # # permanently add port 80

Firewall-cmd-remove-port=80/tcp-permanent # # permanently add port 80

Firewall-cmd-- zone=public-- list-ports # # View open ports

Iptables-L-n # # View the rules, this command is the same as iptables's

Man firewall-cmd

-

1. Turn off the firewall directly

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld.service # prevents firewall from booting

2. Set iptables service

Yum-y install iptables-services

If you want to modify the firewall configuration, such as adding firewall port 3306

Vi / etc/sysconfig/iptables

Add rules

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

After saving and exiting

Systemctl restart iptables.service # restart the firewall to make the configuration effective

Systemctl enable iptables.service # set the firewall to boot

On how to set up the firewall in linux to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Firewall fire protection port service permanent command open rule support configuration success content article more status knowledge article good same function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker MySQL vpn Shulou Tech Info