firewall相关命令

viEcho Lv5

[TOC]
环境:VMware、CentOS8

从centos7开始使用systemctl.firewalld来管理服务和程序,包括了service和chkconfig。

防火墙状态:systemctl status firewalld.service

Active: inactive (dead)/active(running)

关闭firewall:systemctl stop firewalld.service

重启:systemctl restart firewalld.service

启动:systemctl start firewalld.service

禁止firewall开机启动:systemctl disable firewalld.service

设置开机启用:systemctl enable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.service;echo

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看已经开放的端口:firewall-cmd –list-ports

开启端口:firewall-cmd –zone=public –add-port=80/tcp –permanent

命令含义:

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

  • Title: firewall相关命令
  • Author: viEcho
  • Created at : 2020-10-08 00:00:00
  • Updated at : 2024-05-22 00:47:28
  • Link: https://viecho.github.io/2020/1008/firewall-shell.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
firewall相关命令