firewalld/iptables防火墙维护和状态查询命令(防火墙重载,区域操作命令,开启服务或端口,堵塞端口,iptables规则添加和删除)

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=接口(网卡) 为指定接口绑定区域
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值