linux的火墙策略优化

目录

1.实验环境

2.火墙介绍

3.火墙管理切换

4.firewalld

firewalld开启

关于firewalld的域

关于firewalld的设定原理及数据存储

firewalld的管理命令

服务与端口

网络接口,来源

firewalld的高级规则

firewalld中的NAT

SNAT

DNAT

5.iptables

iptables 的使用

火墙默认策略

iptables命令

nat表中的dnat snat


1.实验环境

主机client :网段:1.1.1.212

主机sever:双网卡,

                      网段1:172.25.254.112     网段2:1.1.1.112

  真机:172.25.254.29

2.火墙介绍

  • 在内核上安装的一个数据过滤插件——netfilter,管理与内核进行数据交流的服务

  • 管理iptables插件的策略为firewall和iptables

3.火墙管理切换

  • 由于在rhel8中默认使用的是firewalld,故:由firewalld切换到iptables
dnf install iptables-services -y :安装iptables
systemctl stop firewalld          :暂停firewalld
systemctl disable firewalld       :关闭firewalld
systemctl mask firewalld          :加锁firewalld
systemctl enable --now iptables  :立刻开启iptables

 

  • 由iptables切换到firewalld
dnf install firewalld -y         :安装firewalld
systemctl stop iptables         :暂停iptables 
systemctl disable iptables      :关闭iptables 
systemctl mask iptables         :枷锁iptables 
systemctl unmask firewalld       :解封firewalld 
systemctl enable --now firewalld :立刻开启firewalld

 

4.firewalld

firewalld开启

systemctl stop iptables         :暂停iptables 
systemctl disable iptables      :关闭iptables 
systemctl mask iptables         :枷锁iptables 
systemctl unmask firewalld       :解封firewalld 
systemctl enable --now firewalld :立刻开启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

 

 

 

 

 

 

 

 

 

关于firewalld的设定原理及数据存储

火墙配置目录:/etc/firewalld

火墙模块目录:/lib/firewalld

firewalld的管理命令

firewall-cmd --state                    :查看火墙状态
firewall-cmd --get-active-zones         :查看当前火墙中生效的域
firewall-cmd --get-default-zone         :查看默认域
firewall-cmd --list-all                 :查看默认域中的火墙策略
firewall-cmd --list-all --zone=xxx      :查看指定域(xxx)的火墙策略
firewall
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值