Firewalld防火墙

 

1:firewall-cmd命令

(1)启动、停止、查看firewalld服务

[root@localhost ~]# systemctl start firewalld

[root@localhost ~]# systemctl enable firewalld

[root@localhost ~]# systemctl status firewalld ##能够看到更详细的信息

[root@localhost ~]# firewall-cmd --state ##信息较少

 

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

 

(2)获取预定义信息

[root@localhost ~]# firewall-cmd --get-zones

[root@localhost ~]# firewall-cmd --get-service

[root@localhost ~]# firewall-cmd --get-icmptype

 

(3)区域管理

显示当前系统默认的区域

[root@localhost ~]# firewall-cmd --get-default-zone

public

 

显示默认区域的所有规则

[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: eth0

  sources:

  services: dhcpv6-client ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  sourceports:

  icmp-blocks:

  rich rules:

 

显示网络接口eth0对应区域

[root@localhost ~]# firewall-cmd --get-zone-of-interface=eth0

public

 

将网络接口eth0对应区域改为internal区域

[root@localhost ~]# firewall-cmd --zone=internal --change-interface=eth0

The interface is under control of NetworkManager, setting zone to 'internal'.

success

[root@localhost ~]# firewall-cmd --zone=internal --list-interface

eth0

[root@localhost ~]# firewall-cmd --get-zone-of-interface=eth0

internal

 

 

显示所有激活区域

[root@localhost ~]# firewall-cmd --get-active-zone

internal

  interfaces: eth0

 

(4)服务管理

为默认区域设置允许访问的所有服务

[root@localhost ~]# firewall-cmd --zone=public --change-interface=eth0

[root@localhost ~]# firewall-cmd --list-services

dhcpv6-client ssh

[root@localhost ~]# firewall-cmd --add-service=http

success

[root@localhost ~]# firewall-cmd --add-service=https

success

[root@localhost ~]# firewall-cmd --list-services

dhcpv6-client ssh http https

 

为internal区域设置允许访问的服务

[root@localhost ~]# firewall-cmd --zone=internal --add-service=mysql

success

[root@localhost ~]# firewall-cmd --zone=internal --remove-service=samba-client

success

[root@localhost ~]# firewall-cmd --zone=internal --list-services

ssh mdns dhcpv6-client mysql

 

 

端口管理

[root@localhost ~]# firewall-cmd --zone=internal --add-port=443/tcp

success

[root@localhost ~]# firewall-cmd --zone=internal --remove-port=443/tcp

success

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值