Centos 运维之防火墙篇——②firewalld

简介: 防火墙一般来说,iptables和firewalld启用一个即可

防火墙


一般来说,iptables和firewalld启用一个即可


firewalld


这是CentOS8的默认防火墙


# 允许开机自启systemctl enable firewalld
# 开启服务systemctl start firewalld
# 下面这个好像也可以service firewalld start

firewalld有两个基础概念zoneservice,每个zone里面有不同的iptables规则,默认一共有9个zone,而默认的zone为public


zone
# 获取系统所有zonefirewall-cmd --get-zones# 查看默认的zonefirewall-cmd --get-default-zone


下面是关于zone的命令

# 设置默认的zone为workfirewall-cmd --set-default-zone=work
# 查看指定网卡所在的zonefirewall-cmd --get-zone-of-interface=ens33
# 给指定网卡设置zonefirewall-cmd --zone=public --add-interface=lo
# 针对网卡更改zonefirewall-cmd --zone=dmz --change-interface=lo
# 针对网卡删除zonefirewall-cmd --zone=dmz --remove-interface=lo
# 查看系统所有网卡所在的zonefirewall-cmd --get-active-zones


service


每个zone里都有不同的service,一个service就是针对一个服务(端口)做的iptables规则


# 列出当前系统所有的servicefirewall-cmd --get-service


这些service都是由一个个配置文件定义的,配置文件的模板在`/usr/lib/firewalld/services/`目录下,真正生效的配置在`/etc/firewalld/services/`目录下(默认为空)


# 查看当前zone下有哪些servicefirewall-cmd --list-services# 查看指定zone下有哪些servicefirewall-cmd --zone=public --list-services


# 给zone添加service(仅在内存中生效)firewall-cmd --zone=public --add-service=http
# 若要修改配置文件firewall-cmd --zone=public --add-service=http --permanent


zone下service的配置文件模板在`/usr/lib/firewalld/zones/`,生效的配置文件在`/etc/firewalld/zones/`


类似与iptables的简单方法


# 放行指定端口(范围) # 设置范围直接修改1000为1000-1001即可firewall-cmd --zone=public --add-port1000/tcp --permanent //如果不指定--zone默认就是public
# 重载使规则生效firewall-cmd --reload# 列出当前具体规则firewall-cmd --list-all# 可使用grep过滤firewall-cmd --list-all|grep port
# 删除指定端口firewall-cmd --remove-port8080/tcp --permanent
目录
相关文章
|
12月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu中防火墙配置命令集汇
有了这些,你就能遨游在 CentOS 和 Ubuntu 的海洋中,频繁地改变你的防火墙设置,快速地应对各种安全威胁,同时也能保证你的系统可以正常工作。出发吧,勇敢的编程者,随着这些命令集的涌动,扬帆起航,走向安全的网络世界!
398 5
|
Web App开发 运维 Linux
破防了!原来CentOS联网设置竟藏在这个路径?网友:5年运维都白干了!
默认情况下,新装的 CentOS 无法直接上网。可通过点击桌面右上角的网络图标,启动 `eth0` 连接网络。为实现自动连接,右键该图标选择“编辑连接”,在 `System eth0` 设置中勾选“自动连接”。这样配置后,系统重启也能自动联网。
500 19
破防了!原来CentOS联网设置竟藏在这个路径?网友:5年运维都白干了!
|
安全 Linux 网络安全
centos7中firewall防火墙的常用命令总结
以上命令集覆盖了 `firewalld`的基本操作,是维护CentOS 7系统安全不可或缺的工具。对于更高级的配置需求或遇到特定问题
409 3
|
缓存 运维 Linux
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
深入解析:一步步掌握 CentOS 7 安装全流程及运维实战技巧
|
消息中间件 运维 Linux
linux之centos运维kafka
linux之centos运维kafka
|
运维 Linux
CentOS系统openssh-9,你会的还只有初级Linux运维工程师的技术吗
CentOS系统openssh-9,你会的还只有初级Linux运维工程师的技术吗
|
XML 安全 Linux
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
|
运维 程序员 Linux
运维最全Linux 基本防火墙设置和开放端口命令,2024年最新程序员如何自我学习和成长
运维最全Linux 基本防火墙设置和开放端口命令,2024年最新程序员如何自我学习和成长
|
运维 网络协议 Linux
2024年最全CentOS8 Consul微服务架构安装(1)_agent(1),Linux运维开发面试
2024年最全CentOS8 Consul微服务架构安装(1)_agent(1),Linux运维开发面试
|
网络协议 Linux 网络安全
CentOS 7 防火墙指令
本文介绍了CentOS 7中管理防火墙`firewalld`的指令。
371 0

热门文章

最新文章