linux防火墙
安全技术和防火墙
安全技术
- 入侵检测与管理系统(Intrusion Detection Systems):特点是不阻断任何网络访问,量化、定位来自内外网络的威胁情况,主要以提供报告和事后监督为主,提供有针对性的指导措施和安全决
策依据。一般采用旁路部署方式 - 入侵防御系统(Intrusion Prevention System):以透明模式工作,分析数据包的内容如:溢出攻击、拒绝服务攻击、木马、蠕虫、系统漏洞等进行准确的分析判断,在判定为攻击行为后立即予
以阻断,主动而有效的保护网络的安全,一般采用在线部署方式 - 防火墙( FireWall ):隔离功能,工作在网络或主机边缘,对进出网络或主机的数据包基于一定
的规则检查,并在匹配某规则时由规则定义的行为进行处理的一组功能的组件,基本上的实现都是
默认情况下关闭所有的通过型访问,只开放允许访问的策略
防火墙的分类
- 按保护范围划分:
- 主机防火墙:服务范围为当前主机
- 网络防火墙:服务范围为防火墙一侧的局域网
- 按实现方式划分:
- 硬件防火墙:在专用硬件级别实现部分功能的防火墙;另一个部分功能基于软件实现,如:华为,
- 天融信Checkpoint,NetScreen等
- 软件防火墙:运行于通用硬件平台之上的防火墙的应用软件
- 按网络协议划分:
- 网络层防火墙:OSI模型下四层
- 应用层防火墙/代理服务器:代理网关,OSI模型七层
包过滤防火墙
- 网络层对数据包进行选择,选择的依据是系统内设置的过滤逻辑,被称为访问控制列表(ACL),通过检查数据流中每个数据的源地址,目的地址,所用端口号和协议状态等因素,或他们的组合来确定是否允许该数据包通过
- 优点:对用户来说透明,处理速度快且易于维护
- 缺点:无法检查应用层数据,如病毒等
应用层防火墙
- 应用层防火墙/代理服务型防火墙,也称为代理服务器(Proxy Server)
- 将所有跨越防火墙的网络通信链路分为两段
- 内外网用户的访问都是通过代理服务器上的“链接”来实现
- 优点:在应用层对数据进行检查,比较安全
- 缺点:增加防火墙的负载
提示:现实生产环境中所使用的防火墙一般都是二者结合体,即先检查网络数据,通过之后再送到应用层去检查
Linux 防火墙的基本认识
Netfilter
- Linux防火墙是由Netfilter组件提供的,Netfilter工作在内核空间,集成在linux内核中
- Netfilter 是Linux2.4.x之后新一代的Linux防火墙机制,是linux内核的一个子系统。Netfilter采用模块化设计,具有良好的可扩充性,提供扩展各种网络服务的结构化底层框架。Netfilter与IP协议栈是无缝契合,并允许对数据报进行过滤、地址转换、处理等操作
Netfilter官网文档:https://netfilter.org/documentation/
防火墙工具介绍
iptables
- iptables
由软件包iptables提供的命令行工具,工作在用户空间,用来编写规则,写好的规则被送往netfilter,告诉内核如何去处理信息包
firewalld
- firewalled
从centos7版开始引入新的前端管理工具 - 软件包
- firewalld
- firewalld-config
- 管理工具
- firewalld-cmd命令行工具
- firewalld-config图形工具
nftables
- 此软件是CentOS 8 新特性,Nftables最初在法国巴黎的Netfilter Workshop 2008上发表,然后由长期的netfilter核心团队成员和项目负责人Patrick McHardy于2009年3月发布。它在2013年末合并到Linux内核中,自2014年以来已在内核3.13中可用。
- 它重用了netfilter框架的许多部分,例如连接跟踪和NAT功能。它还保留了命名法和基本iptables设计的几个部分,例如表,链和规则。就像iptables一样,表充当链的容器,并且链包含单独的规则,这些规则可以执行操作,例如丢弃数据包,移至下一个规则或跳至新链。
- 从用户的角度来看,nftables添加了一个名为nft的新工具,该工具替代了iptables,arptables和
ebtables中的所有其他工具。从体系结构的角度来看,它还替换了内核中处理数据包过滤规则集运行时评估的那些部分。
[root@centos8 ~]# iptables --version
iptables v1.8.2 (nf_tables)
[root@centos8 ~]#ll /usr/sbin/iptables
lrwxrwxrwx. 1 root root 17 May 11 2019 /usr/sbin/iptables -> xtables-nft-multi
-----------------------------------------------------------------------------
[root@centos7 ~]# iptables --version
iptables v1.4.21
[root@centos7 ~]#ll /usr/sbin/iptables
lrwxrwxrwx. 1 root root 13 Dec 9 2018 /usr/sbin/iptables -> xtables-multi
------------------------------------------------------------------------------
[root@centos6 ~]#iptables --version
iptables v1.4.7
[root@centos6 ~]#ll /sbin/iptables
lrwxrwxrwx. 1 root root 33 Dec 12 2018 /sbin/iptables -> /etc/alternatives/iptables.x86_64
[root@centos6 ~]#ll /etc/alternatives/iptables.x86_64
lrwxrwxrwx. 1 root root 20 Dec 12 2018 /etc/alternatives/iptables.x86_64 -> /sbin/iptables-1.4.7
[root@centos6 ~]#ll /sbin/iptables
lrwxrwxrwx. 1 root root 33 Dec 12 2018 /sbin/iptables -> /etc/alternatives/iptables.x86_64
范例:查看软件包
[root@cnentos18 ~]# rpm -qi iptables
Name : iptables
Version : 1.8.2
Release : 9.el8
Architecture: x86_64
Install Date: Wed 25 Sep 2019 08:36:58 PM CST
Group : Unspecified
Size : 2050086
License : GPLv2 and Artistic 2.0 and ISC
Signature : RSA/SHA256, Tue 02 Jul 2019 06:50:00 AM CST, Key ID 05b555b38483c65d
Source RPM : iptables-1.8.2-9.el8.src.rpm
Build Date : Sat 11 May 2019 10:21:57 PM CST
Build Host : x86-01.mbox.centos.org
Relocations : (not relocatable)
Packager : CentOS Buildsys <bugs@centos.org>
Vendor : CentOS
URL : http://www.netfilter.org/
Summary : Tools for managing Linux kernel packet filtering capabilities
Description :
The iptables utility controls the network packet filtering code in the
Linux kernel. If you need to set up firewalls and/or IP masquerading,
you should either install nftables or this package.
Note: This package contains the nftables-based variants of iptables and
ip6tables, which are drop-in replacements of the legacy tools.
-----------------------------------------------------------------------
[root@centos17 ~]# rpm -qi iptables
Name : iptables
Version : 1.4.21
Release : 33.el7
Architecture: x86_64
Install Date: Fri 27 Sep 2019 08:18:58 AM CST
Group : System Environment/Base
Size : 1555528
License : GPLv2
Signature : RSA/SHA256, Fri 23 Aug 2019 05:26:19 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : iptables-1.4.21-33.el7.src.rpm
Build Date : Thu 08 Aug 2019 07:42:19 PM CST
Build Host : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.netfilter.org/
Sum