首页 > 其他分享 >安全: nftables基础知识系列之二:查看规则/删除规则

安全: nftables基础知识系列之二:查看规则/删除规则

时间:2024-09-17 15:24:24浏览次数:1  
标签:chain tcp 基础知识 nftables accept 规则 dport table my

一,查看规则

查看所有规则

[root@192 ~]# nft list ruleset
table inet my_table {
        chain my_chain {
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept
                tcp dport 80 accept
                tcp dport 3306 accept
                tcp dport 123 accept
        }
}

查看指定表内的规则

[root@192 ~]# nft list table inet my_table
table inet my_table {
        chain my_chain {
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept
                tcp dport 80 accept
                tcp dport 3306 accept
                tcp dport 123 accept
        }
}

查看指定链内的规则

[root@192 ~]# nft list chain inet my_table my_chain
table inet my_table {
        chain my_chain {
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept
                tcp dport 80 accept
                tcp dport 3306 accept
                tcp dport 123 accept
        }
}

二,删除规则

1,查看得到规则的句柄:

[root@192 ~]# nft --handle list chain inet my_table my_chain
table inet my_table {
        chain my_chain { # handle 9
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept # handle 10
                tcp dport 80 accept # handle 11
                tcp dport 3306 accept # handle 12
                tcp dport 123 accept # handle 13
        }
}

-a参数也可以看到规则的句柄

[root@192 ~]# nft -a list chain inet my_table my_chain
table inet my_table {
        chain my_chain { # handle 9
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept # handle 10
                tcp dport 80 accept # handle 11
                tcp dport 3306 accept # handle 12
                tcp dport 123 accept # handle 13
        }
}

删除 :

[root@192 ~]# nft delete rule inet my_table my_chain handle 11

查看效果:

[root@192 ~]# nft -a list chain inet my_table my_chain
table inet my_table {
        chain my_chain { # handle 9
                type filter hook input priority filter; policy accept;
                tcp dport 22 accept # handle 10
                tcp dport 3306 accept # handle 12
                tcp dport 123 accept # handle 13
        }
}

 

标签:chain,tcp,基础知识,nftables,accept,规则,dport,table,my
From: https://www.cnblogs.com/architectforest/p/18417181

相关文章

  • 安全:nftables:基础知识
    一,policy:1,原文档链接:https://docs.redhat.com/zh_hans/documentation/red_hat_enterprise_linux/9/html/configuring_firewalls_and_packet_filters/assembly_creating-and-managing-nftables-tables-chains-and-rules_getting-started-with-nftables#con_basics-of-nftables......
  • 前端必知必会-Sass 嵌套规则和属性
    文章目录Sass嵌套规则和属性Sass嵌套规则Sass嵌套属性总结Sass嵌套规则和属性Sass嵌套规则Sass允许您以与HTML相同的方式嵌套CSS选择器。查看网站导航的一些Sass代码示例:示例SCSS语法:nav{ ul{ margin:0; padding:0; list-style:none......
  • JAVA 基础知识点(一)
    摘要:本文所介绍知识点去粗取精,有助记忆。1.1 关键词定义:关键词是指被Java语言赋予特殊含义的单词。关键词特点:(1)关键词的字母全部小写;           (2) 代码编辑器对关键词都有高亮显示;如public,class,static。packagecom.itheima.test;importj......
  • ChatGPT中Java相关问答(包括Java基础知识和一些面试题)
    分享一个自己学习Java时的记录ChatGPT中的对话:ChatGPT链接包括如下问题HowtolearnJavainordertobecomeasoftwaredevelopmentengineer,pleasegivedetailsofthestudyprogramaswellasthereferencestudymaterials.详细解释java中的this引用解释一下类、......
  • day04 必备基础知识
    day04必备基础知识今日概要进制单位编码1.进制1.1烽火狼烟古代打仗用烽火狼烟来进行传递信号生活中灯泡的亮与暗用来指示信息(用电来抓耗子,灯亮表示抓到了)用亮灯用1表示,则上述的情景为:110010010100100001计算机本质上都有由晶体管和二极管组成(类比为灯......
  • day03 基础知识
    day03基础知识今日概要switchcase语句,条件判断。for循环语句,循环。goto语法,不太建议使用。字符串格式化,“拼接”数据。运算符1.switch语句packagemainfuncmain(){ //表达式 /* switch1+1{ case1: fmt.Println("等于1") case2: fmt.Println......
  • C++入门基础知识71(高级)——【关于C++ 模板】
    成长路上不孤单......
  • C++入门基础知识69(高级)——【关于C++ 动态内存】
    成长路上不孤单......
  • C++入门基础知识68(高级)——【关于C++ 异常处理】
    成长路上不孤单......
  • 分析负数取模与取余的规则
    目录负数"取模"基本概念修正定义取整规则决定商的值取模和取余不一样.负数"取模"基本概念如果a和d是两个自然数,d非零,可以证明存在两个唯一的整数q和r,满足a=q*d+r,且0<=r<d。其中,q被称为商,r被称为余数。//对应代码intmain(){inta=10;intd=3;printf......