RHEL Linux 7的防火墙firewalld学习总结
本文介绍一下RHEL 7下的防火墙配置工具firewalld。 在RHEL 7之前,我们一般使用iptables防火墙管理工具,其实,iptables与firewalld都不是真正的防火墙,它们都只是用来定义防火墙策略的防火墙管理工具而已,或者说,它们只是一种服务或程序。iptables服务会把配置好的防火墙策略交由内核层面的netfilter网络过滤器来处理,而firewalld服务则是把配置好的防火墙策略交由内核层面的nftables包过滤框架来处理。
firewalld(Dynamic Firewall Manager of Linux systems,Linux系统的动态防火墙管理器),在RHLE 7下是默认的防火墙配置管理工具,它拥有基于CLI(命令行界面 firewalld-cmd)和基于GUI(图形用户界面 firewalld-config)的两种管理方式。相较于传统的防火墙管理配置工具,firewalld支持动态更新技术并加入了区域(zone)的概念。简单来说,区域就是firewalld预先准备了几套防火墙策略集合(策略模板),用户可以根据生产场景的不同而选择合适的策略集合,从而实现防火墙策略之间的快速切换。它具备对IP V4和IP V6防火墙设置的支持。
防火墙中的一切都与一个或者多个区域相关联,下面对各个区进行说明:
Zone Description
-----------------------------------------------------
drop (immutable) Deny all incoming connections, outgoing ones are accepted.
block (immutable) Deny all incoming connections, with ICMP host prohibited messages issued.
trusted (immutable) Allow all network connections
public Public areas, do not trust other computers
external For computers with masquerading enabled, protecting a local network
dmz For computers publicly accessible with restricted access.
work For trusted work areas
home For trusted home network connections
internal For internal network, restrict incoming connections
drop(丢弃)
任何流入网络的包都被丢弃,不作出任何响应,只允许流出的网络连接。即使开放了某些服务(比如http),这些服务的数据也是不允许通过的。
block(限制)
任何进入的网络连接都被拒绝,并返回IPv4的icmp-host-prohibited报文或者IPv6的icmp6-adm-prohibited 报文。只允许由该系统初始化的网络连接。
trusted(信任)
可接受所有的网络连接。允许所有网络连接,即使没有开放任何服务,那么使用此zone的流量照样通过(一路绿灯)
public(公共)
在公共区域内使用,不能相信网络内的其他计算机不会对您的计算机造成危害,只能接收经过选取的连接。
external(外部)
特别是为路由器启用了伪装功能的外部网。您不能信任来自网络的其他计算,不能相信它们不会对您的计算机造成危害,只能接收经过选择的连接。
dmz(非军事区)
用以允许隔离区(dmz)中的电脑有限地被外界网络访问,只允许选中的服务通过。
work(工作)
用于工作区。您可以基本相信网络内的其他电脑不会危害您的电脑。只允许选中的服务通过。
home(家庭)
用于家庭网络。您可以基本信任网络内的其他计算机不会危害您的计算机。,只允许选中的服务通过。
internal(内部)
用于内部网络。您可以基本上信任网络内的其他计算机不会威胁您的计算机。只允许选中的服务通过。
检查防火墙工具
如果你要判断RHEL 7使用的是iptables还是firewalld,那么可以通过命令来判断
有iptables的情况:
# systemctl status iptables.service
● iptables.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
没有iptables的情况
# systemctl status iptables.service
Unit iptables.service could not be found.
当然,最简单的方法是使用下面命令来判别
# systemctl is-active firewalld
active
# systemctl is-active iptables
inactive
# systemctl is-active ip6tables
inactive
# systemctl is-active ebtables
inactive
查看防火墙状态
# systemctl status firewalld
# firewall-cmd --state
[root@mylnx ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-03-07 11:46:34 HKT; 1 day 4h ago
Main PID: 124126 (firewalld)
CGroup: /system.slice/firewalld.service
└─124126 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Mar 07 11:46:34 mylnx systemd[1]: Starting firewalld - dynamic firewall daemon...
参与评论
手机查看
返回顶部