search
HomeOperation and MaintenanceLinux Operation and MaintenanceDetailed explanation of the firewall settings you need to pay attention to when building a web server on CentOS

Detailed explanation of the firewall settings that need to be paid attention to when building a web server on CentOS

Introduction:
When building a web server on CentOS, firewall settings are a very important content. Correct firewall settings can effectively protect server security and prevent malicious attacks. This article will introduce in detail the firewall settings that need to be paid attention to when building a web server on CentOS, and provide corresponding code examples for readers' reference and learning.

1. Understand the basic knowledge of CentOS firewall
The default firewall tool used by CentOS is "firewalld". Firewalld is a web-based firewall management tool that uses dynamic and static firewall rules to protect servers. Understanding the basic knowledge of Firewalld is a prerequisite for firewall settings.

2. Check the Firewalld version on the server
Before starting to configure the firewall, you first need to check whether Firewall has been installed on the server and check its version. Use the following command to check:

firewall-cmd --version

If the returned result is the version number of Firewalld, it proves that Firewalld has been installed on the server.

3. Check the status of Firewalld
Before configuring the firewall, you need to know the current status of Firewalld. The following command can check the status of Firewalld:

systemctl status firewalld

If Active (running) is displayed, it means Firewalld is running.

4. Enabling, disabling and restarting Firewalld

  1. Enable Firewalld:
systemctl start firewalld
  1. Disable Firewalld:
systemctl stop firewalld
  1. Restart Firewalld:
systemctl restart firewalld

5. Set up to allow the specified port to pass through the firewall
The following takes port 80 as an example to demonstrate how to set up to allow the specified port to pass through the firewall.

  1. Add port 80:
firewall-cmd --zone=public --add-port=80/tcp --permanent
  1. Reload Firewalld configuration:
firewall-cmd --reload

6. Set up to allow specified IP addresses to pass through the firewall
The following takes allowing 192.168.1.100 to pass through the firewall as an example.

  1. Add allowed IP addresses:
firewall-cmd --permanent --zone=public --add-source=192.168.1.100
  1. Reload Firewalld configuration:
firewall-cmd --reload

7. Set allowed specified ports and IP address passes through the firewall
The following is an example of allowing the IP address of 192.168.1.100 and port 80 to pass through the firewall.

  1. Add allowed IP addresses and ports:
firewall-cmd --permanent --zone=public --add-source=192.168.1.100
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload

8. View firewall configuration rules
Use the following command to view the current Firewalld rule configuration:

firewall-cmd --list-all

9. Summary:
This article introduces the firewall settings that need to be paid attention to when building a web server on CentOS. By understanding the basics of firewalls, we can better protect server security. I hope this article will be helpful to readers, and also remind readers to update and check the server's firewall settings in a timely manner to ensure the security of the server.

The above is a detailed explanation of the firewall settings that need to be paid attention to when building a web server on CentOS. I hope it will be helpful to you. thanks for reading!

The above is the detailed content of Detailed explanation of the firewall settings you need to pay attention to when building a web server on CentOS. 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
Tutorial on finding keywords for common Linux commandsTutorial on finding keywords for common Linux commandsMar 05, 2025 am 11:45 AM

This tutorial demonstrates efficient keyword searching in Linux using the grep command family and related tools. It covers basic and advanced techniques, including regular expressions, recursive searches, and combining commands like awk, sed, and xa

Work content of Linux operation and maintenance engineers What does Linux operation and maintenance engineers do?Work content of Linux operation and maintenance engineers What does Linux operation and maintenance engineers do?Mar 05, 2025 am 11:37 AM

This article details the multifaceted role of a Linux system administrator, encompassing system maintenance, troubleshooting, security, and collaboration. It highlights essential technical and soft skills, salary expectations, and diverse career pr

How do I configure SELinux or AppArmor to enhance security in Linux?How do I configure SELinux or AppArmor to enhance security in Linux?Mar 12, 2025 pm 06:59 PM

This article compares SELinux and AppArmor, Linux kernel security modules providing mandatory access control. It details their configuration, highlighting the differences in approach (policy-based vs. profile-based) and potential performance impacts

How do I back up and restore a Linux system?How do I back up and restore a Linux system?Mar 12, 2025 pm 07:01 PM

This article details Linux system backup and restoration methods. It compares full system image backups with incremental backups, discusses optimal backup strategies (regularity, multiple locations, versioning, testing, security, rotation), and da

How do I use regular expressions (regex) in Linux for pattern matching?How do I use regular expressions (regex) in Linux for pattern matching?Mar 17, 2025 pm 05:25 PM

The article explains how to use regular expressions (regex) in Linux for pattern matching, file searching, and text manipulation, detailing syntax, commands, and tools like grep, sed, and awk.

How do I monitor system performance in Linux using tools like top, htop, and vmstat?How do I monitor system performance in Linux using tools like top, htop, and vmstat?Mar 17, 2025 pm 05:28 PM

The article discusses using top, htop, and vmstat for monitoring Linux system performance, detailing their unique features and customization options for effective system management.

How do I implement two-factor authentication (2FA) for SSH in Linux?How do I implement two-factor authentication (2FA) for SSH in Linux?Mar 17, 2025 pm 05:31 PM

The article provides a guide on setting up two-factor authentication (2FA) for SSH on Linux using Google Authenticator, detailing installation, configuration, and troubleshooting steps. It highlights the security benefits of 2FA, such as enhanced sec

Methods for uploading files for common Linux commandsMethods for uploading files for common Linux commandsMar 05, 2025 am 11:42 AM

This article compares Linux commands (scp, sftp, rsync, ftp) for uploading files. It emphasizes security (favoring SSH-based methods) and efficiency, highlighting rsync's delta transfer capabilities for large files. The choice depends on file size,

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)