Linux Centos firewalld 使用

一、 firewalld 基操

start: systemctl start firewalld

stop: systemctl stop firewalld

status: systemctl status firewalld

开机禁用 : systemctl disable firewalld

开机启用 : systemctl enable firewalld

二、systemctl介绍

启动服务:systemctl start firewalld.service

关闭服务:systemctl stop firewalld.service

重启服务:systemctl restart firewalld.service

显示服务的状态:systemctl status firewalld.service

在开机时启用服务:systemctl enable firewalld.service

在开机时禁用服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed

三、firewalld-cmd 命令

1、查看版本: firewall-cmd --version

2、查看帮助: firewall-cmd --help

3、显示状态: firewall-cmd --state

4、查看所有打开的端口: firewall-cmd --zone=public --list-ports

5、更新防火墙规则: firewall-cmd --reload

6、查看区域信息: firewall-cmd --get-active-zones

7、查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

8、拒绝所有包:firewall-cmd --panic-on

9、取消拒绝状态: firewall-cmd --panic-off

10、查看是否拒绝: firewall-cmd --query-panic

四、端口操作命令

1、添加:firewall-cmd --zone=public --add-port=1222/tcp --permanent

-permanent永久生效,没有此参数重启后失效

2、重载:firewall-cmd --reload

3、查看:firewall-cmd --zone= public --query-port=1222/tcp

4、删除:firewall-cmd --zone= public --remove-port=1222/tcp --permanent

五、 访问连接配置

1、ssh 连接允许指定ip访问

firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.0.1" port protocol="tcp" port="22" accept'

2、ssh 拒绝指定ip

firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.0.1" port protocol="tcp" port="22" reject'

3、ssh 连接 移除公共访问

firewall-cmd --permanent --zone=public --remove-service=ssh

4、ssh连接放开访问

firewall-cmd --permanent --zone=public --add-service=ssh

相关推荐
马立杰3 小时前
H3CNE-33-BGP
运维·网络·h3cne
云空4 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
深度Linux4 小时前
Linux网络编程中的零拷贝:提升性能的秘密武器
linux·linux内核·零拷贝技术
没有名字的小羊4 小时前
Cyber Security 101-Build Your Cyber Security Career-Security Principles(安全原则)
运维·网络·安全
千夜啊5 小时前
Nginx 运维开发高频面试题详解
运维·nginx·运维开发
存储服务专家StorageExpert6 小时前
答疑解惑:如何监控EMC unity存储系统磁盘重构rebuild进度
运维·unity·存储维护·emc存储
太阳伞下的阿呆7 小时前
排查定位jar包大文件
java·centos·jar
chian-ocean7 小时前
从理论到实践:Linux 进程替换与 exec 系列函数
linux·运维·服务器
拎得清n7 小时前
UDP编程
linux
敖行客 Allthinker8 小时前
从 UTC 日期时间字符串获取 Unix 时间戳:C 和 C++ 中的挑战与解决方案
linux·运维·服务器·c++