Linux中的火墙策略优化

实验环境:

主机nodea设置双网卡,ip为172.25.254.111   172.25.11.111

主机nodeb设置ip为172.25.11.211 安装firefox

一、火墙介绍

1.netfilter
2.iptables
3.iptables|firewalld

二、火墙管理工具切换

在rhel8中默认使用的是firewalld
firewalld----->iptables

[root@westoslinux ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@westoslinux ~]# systemctl mask firewalld ##冻结
Created symlink /etc/systemd/system/firewalld.service → /dev/null.
[root@westoslinux ~]# systemctl enable --now iptables
[root@westoslinux ~]# iptables -nL  ##查看

iptales -------> fiewalld

[root@westoslinux ~]# systemctl disable --now iptables.service 
[root@westoslinux ~]# systemctl mask iptables.service 
[root@westoslinux ~]# systemctl unmask firewalld.service 
[root@westoslinux ~]# systemctl enable --now firewalld
[root@westoslinux ~]# systemctl status firewalld.service 

三、firewalld

1、firewalld的开启

[root@westoslinux ~]# systemctl disable --now iptables.service 
[root@westoslinux ~]# systemctl mask iptables.service 
[root@westoslinux ~]# systemctl unmask firewalld.service 
[root@westoslinux ~]# systemctl enable --now firewalld

2、关于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

[root@westoslinux ~]# firewall-cmd --get-zones  ##查看所有关于firewalld 的域
block dmz drop external home internal public trusted work 
[root@westoslinux ~]# dnf install httpd -y  ##安装httpd并打开服务
[root@westoslinux ~]# systemctl enable --now httpd

但此时无法访问172.25.254.111

查看默认域,查看默认域中的火墙策略中没有httpd,所以无法访问

 将默认域设置为trusted完全信任,此时可以访问172.25.254.111

 

 删除block域中的http服务,将默认域改为block,此时无法访问172.25.254.111

 

 设置允许火墙通过http服务,此时可以访问172.25.254.111

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值