首页 > 其他分享 >firewall-cmd相关

firewall-cmd相关

时间:2023-05-22 11:44:26浏览次数:38  
标签:查看 firewall cmd firewalld -- systemctl 相关

使用命令 firewall-cmd --list-all,查看到firewall 当前的状态列表。

 1 public (active)
 2   target: default
 3   icmp-block-inversion: no
 4   interfaces: wlo1
 5   sources:
 6   services: dhcpv6-client ftp ssh
 7   ports: 22/tcp
 8   protocols:
 9   forward: yes
10   masquerade: no
11   forward-ports:
12   source-ports:
13   icmp-blocks:
14   rich rules:

查看firewall支持的服务,使用命令:

firewall-cmd --get-services | grep tftp

从结果可知支持tftp。

 

1.firewalld的基本使用

启动: systemctl start firewalld
查状态:systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

2.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic

3.那怎么开启一个端口/服务呢

添加

 1 firewall-cmd --zone=public(作用域) --add-port=80/tcp(端口和访问类型) --permanent(永久生效)
 2 firewall-cmd --zone=public --add-service=http --permanent
 3 firewall-cmd --reload    # 重新载入,更新防火墙规则
 4 firewall-cmd --zone= public --query-port=80/tcp  #查看
 5 firewall-cmd --zone= public --remove-port=80/tcp --permanent  # 删除
 6 
 7 firewall-cmd --list-services  //查看当前通过的服务
 8 firewall-cmd --get-services //查看firewall支持的服务
 9 firewall-cmd --add-service=<service> 
10 firewall-cmd --delete-service=<service>

在每次修改端口和服务后/etc/firewalld/zones/public.xml文件就会被修改,所以也可以在文件中之间修改,然后重新加载
使用命令实际也是在修改文件,需要重新加载才能生效。

4.参数解释

–add-service #添加的服务
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

 

 

————————————————
版权声明:本文为CSDN博主「爱烫头的hiram」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zouyh/article/details/125787163

标签:查看,firewall,cmd,firewalld,--,systemctl,相关
From: https://www.cnblogs.com/FBsharl/p/17420222.html

相关文章

  • Flask相关配置参数,加载配置文件
    Flask相关配置参数,加载配置文件#导入Flask类fromflaskimportFlask#Flask函数接收一个参数__name__,它会指向程序所在的包app=Flask(__name__)#装饰器的作用是将路由映射到视图函数[email protected]('/')defindex():return'HelloWorld'#Flask应用程......
  • 相关数据进行训练(以心脏器官为例)
    数据训练1、下载相关数据(Task02_Heart)得到这样结构的数据:与教程中的Lung数据相符:2、使用命令进行数据训练pythontrain.py--config**configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold0.yml**这里放置本机的文件路径--log_iters20--precisionfp16--nnunet-......
  • Openresty 学习笔记(二)Nginx Lua 正则表达式相关API
    ngx.re.match语法: captures,err=ngx.re.match(subject,regex,options?,ctx?,res_table?)环境: init_worker_by_lua*,set_by_lua*,rewrite_by_lua*,access_by_lua*,content_by_lua*,header_filter_by_lua*,body_filter_by_lua*,log_by_lua*,ngx.timer.*,balancer......
  • 1.脚本高级命令,进程优先级命令,进程管理工具,任务相关命令
    一.总结脚本高级命令trap,install,mktemp,expect,进程优先级命令:nice,renice,进程管理工具:ps,pstree,prtstat,pgrep,pidof,uptime,mpstat,top,htop,free,pmap,vmstat,iostat,iotop,iftop,nload,nethogs,iptraf-ng,dstat,glances,cockpit,kill,job,任务......
  • 3.进程相关
    解析进程和线程的区别进程进程是一个具有独立功能的程序在一个数据集上的一次动态执行过程,是操作系统进行资源分配和调度的一个独立单位,是应用程序运行的载体。进程是一种抽象的概念,从来没有统一的标准定义。进程一般由程序,数据集合和进程控制块三部分组成。进程具有的特性:动态性:......
  • 荐号 | Android 相关的公号推荐
    之前有部分人觉得我的文章更新慢,那么今天就来给大家推荐一些Android相关的其他公号,这些公号的作者都是我比较熟的圈内朋友,也是大家熟知的比较活跃的一些分享者,他们在业余时间也在进行原创分享,不过阅读量都不怎么大,所以很希望这些好的原创文章能被更多的人看到,大家可以按照自己的......
  • Matlab字符串相关操作-拼接、格式化
    ✅作者简介:热爱科研的算法开发者,Python、Matlab项目可交流、沟通、学习。......
  • 树相关知识点--零碎笔记
    深入理解前中后序二叉树的前中后序遍历是什么?前中后序遍历,即二叉树结构的前中后位置前序遍历-即刚刚进入一个节点的时候中序遍历-即进入节点之后未离开节点之前后序遍历-即即将离开第一个节点的时候前中后序是遍历二叉树过程中处理每一个节点的三个特殊时间点前--刚刚进入一个二......
  • cmd python pip 笔记
    ......
  • 数据库相关概念
    一:概念分析   数据库系统:分为两部分:一部分是数据库按一定的方式存储数据;另一部分数据库管理系统,为用户及应用程序提供数据访问,并具有对数据库进行管理、维护等功能。   数据库:若干数据的集合体。数据库要由数据库管理系统进行科学的组织和管理,以确保数据库的安全性和完......