Linux的火墙策略优化

实验环境准备

westosa:
双网卡(vim 两个文件   ifcfg-ens3   ifcfg-ens9)
设定两个网段:
网卡1:172.25.254.112
网卡2:1.1.1.112

westosb:

单网卡:1.1.1.212

真机:
172.25.254.12

1.火墙介绍

火墙:在内核上安装的一个数据过滤表(数据过滤插件)——netfilter,管理策略。
通过iptables或firewalld来管理iptables这个插件
1.netfilter
2.iptables
3.iptables|firewalld

2.火墙管理工具切换

在rhel8中默认使用的是firewalld

irewalld--->iptables

dnf install iptables-services -y
systemctl stop firewalld
systemctl disable --now firewalld
##关闭firewalld
systemctl mask firewalld
##封锁firewalld
systemctl enable --now iptables
##开启iptables

 

iptables--->firewalld
dnf install firewalld -y
systemctl stop iptables
systemctl disable --now iptables.service
##关闭iptables服务
systemctl mask iptables
systemctl unmask --now firewalld
##解锁firewalld服务
systemctl enable --now firewalld
##开启firewalld服务
firewall-cmd --list-all
##查看firewalld策略

 2.关于firewalld的域

      firewalld通过将网络划分成不同的区域,制定出不同区域之间的访问控制策略来控制不同程序区域间传送的数据流,具体划分区域如下:

trusted  ##接受所有的网络连接
home     ##用于家庭网络,允许接收ssh mdns ipp-client samba-client dhcp-client
work     ##工作网络 ssh ipp-client dhcp-client
public   ##公共网络 ssh dhcp-client
dmz      ##军级网络 ssh
block    ##拒绝所有
drop     ##丢弃 所有数据全部丢弃无任何回复
internal ##内部网络 ssh mdns ipp-client samba-client dhcp-client
external ##ipv4网络地址伪装转发 sshd

3.关于firewall的设定原理及数据存储

/etc/firewalld ##火墙配置目录
/lib/firewalld ##火墙模块目录

 4.firewalld的管理命令

firewall-cmd --state		##查看火墙状态 
firewall-cmd --get-active-zones ##查看当前火墙中生效的域
firewall-cmd --get-default-zone ##查看默认域
firewall-cmd --list-all		##查看默认域中的火墙策略

firewall-cmd --list-all-zones
##列出所有的域的信息
firewall-cmd --get-zones
##查看域

注:两条命令的区别:

 通过修改域的类型控制http服务

syst
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值