文章目录
firewalld防火墙维护和状态查询命令
[root@localhost ~]# systemctl stop firewalld· 关闭防火墙
[root@localhost ~]# systemctl start firewalld 开启防火墙
[root@localhost ~]# systemctl restart firewalld 重启防火墙
[root@localhost ~]# systemctl status firewalld 状态防火墙
firewalld防火墙状态查询命令
[root@localhost ~]# systemctl status firewalld.service '//查看防火墙状态'
[root@localhost ~]# firewall-cmd --stat '//查看防火墙状态'
firewalld防火墙重载配置命令
重新加载firewalld的配置
[root@localhost ~]# firewall-cmd --reload 重启防火墙
success
[root@localhost ~]# firewall-cmd --complete-reload 状态信息将会丢失,多用于处理防火墙出现问题时
successb
[root@localhost ~]# systemctl restart firewalld.service 重启防火墙
查询预定义信息命令
查看预定义的区域
[root@localhost ~]# firewall-cmd --get-zones
block dmz drop external home internal public trusted work '//默认网络区域'
查看预定义的服务
[root@localhost ~]# firewall-cmd --get-services
RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc
查看预定义的ICMP类型(过滤器)
[root@localhost ~]# firewall-cmd --get-icmptypes
address-unreachable bad-header communication-prohibited destination-unreachable echo
firewalld区域操作命令
显示网络连接或接口的默认区域
[root@localhost ~]# firewall-cmd --get-default-zone
public
设置网络连接或接口的默认区域为internal
[root@localhost ~]# firewall-cmd --set-default-zone=internal
success
显示已激活的所有区域
[root@localhost ~]# firewall-cmd --get-active-zones
internal
interfaces: ens33
区域操作命令2
显示ens33接口绑定的区域
[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens33
public
为ens33接口绑定work区域
[root@localhost ~]# firewall-cmd --zone=work --add-interface=ens33
success
[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens33
work
为work区域更改绑定的网络接口ens33
[root@localhost ~]# firewall-cmd --zone=work --change-interface=ens33
success
[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens33
work
为work区域删除绑定的网络接口ens33
[root@localhost ~]# firewall-cmd --zone=work --remove-interface=ens33
The interface is under control of NetworkManager, setting zone to default.
success
如果出现下面情况删除一下
[root@localhost ~]# firewall-cmd --zone=work --add-interface=ens33
Error: ZONE_CONFLICT: 'ens33' already bound to a zone
[root@localhost ~]# firewall-cmd --zone=public --remove-interface=ens33
success
[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens33
no zone
[root@localhost ~]# firewall-cmd --zone=work --add-interface=ens33
success
[root@localhost ~]# firewall-cmd --get-zone-of-interface=ens33
work
firewalld区域操作命令3
查询work区域中是否包含接口ens33
[root@localhost ~]# firewall-cmd --zone=work --query-interface=ens33
yes
显示区域及其规则
[root@localhost ~]# firewall-cmd --list-all-zones
block
target: %%REJECT%%
icmp-block-inversion: no
interfaces:
sources:
services:
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
等...
显示internal区域的所有规则
[root@localhost ~]# firewall-cmd --zone=internal --list-all
显示默认区域的所有规则
[root@localhost ~]# firewall-cmd --list-all
internal (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh mdns samba-client dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
...省略内容
区域操作命令总结
命令选项 | 说明 |
---|---|
–get-default-zone | 显示网络连接或接口的默认区域 |
–set-default-zone=区域类型 | 设置网络连接或接口的默认区域 |
–get-active-zones | 显示已激活的所有区域 |
–get-zone-of-interface=接口(网卡) | 显示指定接口绑定的区域 |
–zone=区域类型 --add-interface=接口(网卡) | 为指定接口绑定区域 |