CentOS7防火墙

本文介绍了如何在CentOS7中操作firewalld服务,包括重启、启动、关闭防火墙,查看防火墙规则,以及添加和删除端口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CentOS7的firewall

防火墙重启

service firewalld restart

防火墙启动

service firewalld start

防火墙关闭

service firewalld stop

查看防火墙的清单

firewall-cmd --list-all

增加端口

firewall-cmd --zone=public --add-port=27017/tcp --permanent

删除端口

firewall-cmd --zone=public --remove-port=27017/tcp --permanent

查看端口

firewall-cmd --zone=public --query-port=27017/tcp

[root@localhost x]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: ssh dhcpv6-client
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

[root@localhost x]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
[root@localhost x]# service firewalld start
Redirecting to /bin/systemctl start firewalld.service
[root@localhost x]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@localhost x]# firewall-cmd --zone=public --add-port=27017/tcp --permanent 
success
[root@localhost x]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@localhost x]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: ssh dhcpv6-client
  ports: 27017/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

[root@localhost x]# firewall-cmd --zone=public --remove-port=27017/tcp --permanent
success
[root@localhost x]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@localhost x]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: ssh dhcpv6-client
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

[root@localhost x]# firewall-cmd --zone=public --add-port=27017/tcp --permanent
success
[root@localhost x]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@localhost x]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: ssh dhcpv6-client
  ports: 27017/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
[root@localhost x]# firewall-cmd --zone=public --list-ports
27017/tcp
[root@localhost x]# firewall-cmd --zone=public --query-port=27017/tcp
yes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值