🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

CentOS7 firewall management commands

The default firewall in CentOS7 has changed from iptables to firewall. AlthoughBaota Panel can directly add firewall rules graphically, Naiba still has some servers without LNMP installed. Here are the CentOS7 firewall management commands for reference

CentOS7 firewall management commands

firewall status management commands

Command to start firewalld
systemctl start firewalld
Command to stop firewall
systemctl stop firewalld
Command to disable firewall
systemctl disable firewalld

Check firewall status
systemctl status firewalld
Command to restart firewall
systemctl restart firewalld
Check if firewall starts on boot
systemctl is-enabled firewalld

firewall port management commands

Command to open a port in firewall (--permanent takes effect permanently; without this parameter, it becomes invalid after reboot)
firewall-cmd --zone=public --add-port=80/tcp --permanent
Command to delete a port in firewall
firewall-cmd --zone= public --remove-port=80/tcp --permanent
Command to open a port range in firewall
firewall-cmd --permanent --zone=public --add-port=100-500/tcp
firewall-cmd --permanent --zone=public --add-port=100-500/udp
After adding, reload the firewall rules once, otherwise it won't take effect. Reload firewall rules
firewall-cmd --reload
If not enabled, new rules cannot be loaded, so you need to start the firewall first. The command is as follows
systemctl start firewalld
Configure firewalld-cmd
查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step.

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: