当前位置:   article > 正文

Centos7防火墙常用配置命令_centos 7.4 firewall-cmd --list-all icmp-block-inve

centos 7.4 firewall-cmd --list-all icmp-block-inversion

原文 超链接…
原作者 伯牙绝音…


1、查看firewall服务状态

systemctl status firewalld

执行结果----
[root@localhost /]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since 四 2021-12-09 16:05:45 CST; 2min 16s ago
     Docs: man:firewalld(1)
 Main PID: 3053 (firewalld)
    Tasks: 2
   Memory: 28.4M
   CGroup: /system.slice/firewalld.service
           └─3053 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

12月 09 16:05:45 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
12月 09 16:05:45 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
12月 09 16:05:46 localhost.localdomain firewalld[3053]: WARNING: AllowZoneDrifting is enabled. This is considered an in... now.
12月 09 16:06:29 localhost.localdomain firewalld[3053]: WARNING: AllowZoneDrifting is enabled. This is considered an in... now.
Hint: Some lines were ellipsized, use -l to show in full.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

2、查看firewall的状态

firewall-cmd --state

执行结果--
[root@localhost /]# firewall-cmd --state
running
  • 1
  • 2
  • 3
  • 4
  • 5

3、开启、重启、关闭、firewalld.service服务

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4、查看防火墙规则

firewall-cmd --list-all 

执行结果--
[root@localhost /]# firewall-cmd --list-all 
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: dhcpv6-client ssh
  ports: 3360/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

5、查询、开放、关闭端口

# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

操作端口后需要重启防火墙

#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
# 参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/552553
推荐阅读
相关标签
  

闽ICP备14008679号