Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up Firewall in linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report