实验环境:
主机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