自定义链存在的意义:对链进行分类

target可能是一个“动作“也可能是一个”自定义链”

1.新增自定义链。

root@ubuntu:~# iptables -t filter -N IN_WEB
#结果
root@ubuntu:~# iptables -nvL
Chain INPUT (policy ACCEPT 23 packets, 1448 bytes)
pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 16 packets, 1212 bytes)
pkts bytes target prot opt in out source destination Chain IN_WEB (0 references)
pkts bytes target prot opt in out source destination

 

2.引用自定义链。

root@ubuntu:~# iptables -t filter -I INPUT -p tcp --dport 80 -j IN_WEB
#结果
root@ubuntu:~# iptables -nvL
Chain INPUT (policy ACCEPT 11 packets, 770 bytes)
pkts bytes target prot opt in out source destination
0 0 IN_WEB tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 4 packets, 480 bytes)
pkts bytes target prot opt in out source destination Chain IN_WEB (1 references)
pkts bytes target prot opt in out source destination

  

3.重命名自定义链。

root@ubuntu:~# iptables -E IN_WEB WEB

root@ubuntu:~# iptables -nvL
Chain INPUT (policy ACCEPT 53 packets, 3639 bytes)
pkts bytes target prot opt in out source destination
0 0 WEB tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 36 packets, 2840 bytes)
pkts bytes target prot opt in out source destination Chain WEB (1 references)
pkts bytes target prot opt in out source destination

  

4.删除自定义链。

root@ubuntu:~# iptables -X WEB
iptables: Too many links.
#被引用了无法删除
root@ubuntu:~# iptables --line -nvL
Chain INPUT (policy ACCEPT 366 packets, 32141 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 WEB tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 137 packets, 11248 bytes)
num pkts bytes target prot opt in out source destination Chain WEB (1 references)
num pkts bytes target prot opt in out source destination
#删除引用自定义链的条目
root@ubuntu:~# iptables -D INPUT 1
root@ubuntu:~#
root@ubuntu:~# iptables -nvL
Chain INPUT (policy ACCEPT 70 packets, 4797 bytes)
pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 35 packets, 2848 bytes)
pkts bytes target prot opt in out source destination Chain WEB (0 references)
pkts bytes target prot opt in out source destination #可正常删除
root@ubuntu:~# iptables -X WEB
root@ubuntu:~#
root@ubuntu:~# iptables -nvL
Chain INPUT (policy ACCEPT 33 packets, 2104 bytes)
pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 23 packets, 1860 bytes)
pkts bytes target prot opt in out source destination

 删除的条件:

1.自定义链中无规则

2.自定义链没有被其他的链所引用 

iptables详解(8)iptables自定义链的更多相关文章

  1. iptables详解(10):iptables自定义链

    前文中,我们一直在定义规则,准确的说,我们一直在iptables的默认链中定义规则,那么此处,我们就来了解一下自定义链. 你可能会问,iptables的默认链就已经能够满足我们了,为什么还需要自定义链 ...

  2. iptables详解--转

    出处:http://yijiu.blog.51cto.com/433846/1356254 iptables详解 基本概念: 1.防火墙工作在主机边缘:对于进出本网络或者本主机的数据报文,根据事先设定 ...

  3. Iptables详解七层过滤

    <Iptables详解七层过滤> 一.防火墙简介 防火墙其实就是一个加固主机或网络安全的一个设备或者软件而已,通过防火墙可以隔离风险区域与安全区域的连接,同时不会妨碍风险区域的访问.当然需 ...

  4. iptables详解之filter

    iptables详解之filter iptables令很多小伙伴脑阔疼,下面我们来说说如何使用iptables. 一.iptables格式 1.1.iptables 帮助 通过iptables --h ...

  5. 《iptables详解 》RHEL6

          iptables详解    Iptables原理 现在防火墙主要分以下三种类型:包过滤.应用代理.状态检测 包过滤防火墙:现在静态包过滤防火墙市面上已经看不到了,取而代之的是动态包过滤技术 ...

  6. Linux防火墙iptables详解

    iptables详解(思维导图) 1. 概述 1.1 iptable简介 1.2 防火墙的种类 1.3 netfilter 2. iptables的工作流程 2.1 iptables工作图示 2.2 ...

  7. 详解Springboot中自定义SpringMVC配置

    详解Springboot中自定义SpringMVC配置 WebMvcConfigurer接口 ​ 这个接口可以自定义拦截器,例如跨域设置.类型转化器等等.可以说此接口为开发者提前想到了很多拦截层面的需 ...

  8. iptables详解

    Netfilter包含有三种表,三种表下共包含有五种链,链下面包含各种规则.即表包含若干链,链包含若干规则.  (一)三种表为:filter   nat  mangle 1.filter:处理与本机有 ...

  9. iptables 详解

    一:前言   防火墙,其实说白了讲,就是用于实现Linux下访问控制的功能的,它分为硬件的或者软件的防火墙两种.无论是在哪个网络中,防火墙工作的地方一定是在网络的边缘.而我们的任务就是需要去定义到底防 ...

随机推荐

  1. [组合数学][多项式][拉格朗日插值]count

    源自 ditoly 大爷的 FJ 省队集训课件 Statement 有 \(m\) 个正整数变量,求有多少种取值方案 使得所有变量的和不超过 \(S\) 并且前 \(n\) 个变量的值都不超过 \(t ...

  2. 可视化限流管理,Sentinel 控制台启动和接入

    Sentinel 的使用可以分为核心库和控制台两个部分. 核心库不依赖任何框架/库,集成了主流框架,可以进行单机限流降级等功能, 控制台Dashboard提供了可视化的管理限流规则.对集群进行监控,集 ...

  3. 程序员你为什么这么累【三】:编码习惯之Controller规范

    作者:晓风轻本文转载自:https://zhuanlan.zhihu.com/p/28717374 第一篇文章中,我贴了2段代码,第一个是原生态的,第2段是我指定了接口定义规范,使用AOP技术之后最终 ...

  4. 编程基础系列--之--浅谈List、Set、Map和泛型(一)——单列集合

    之前在学习Java时对于泛型,集合的理解一直模模糊糊,随着时间的推移,对泛型和集合有了一些浅显的认知,打算写出来巩固一下,也希望各位大佬能指出理解不当之处,万分感谢!!! 在Java语言中,集合分为两 ...

  5. 废旧手机改造之给你的手机安装win10系统

    最近又开始琢磨把我这个即将退出的二手手机再利用一下 发现了一个不错的软件 先上图 是不是感觉逼格很高啊 点击下面链接即可下载使用 https://www.lanzous.com/i4gpsib 欢迎交 ...

  6. scanf 函数笔记

    函数声明 int scanf(const char *format, ...); 说明 <返回值> scanf ("<格式化字符串>", <参数表&g ...

  7. SpringCloud与微服务Ⅶ --- Feign负载均衡

    官方文档:https://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign 一.Feign是什么 Feign是一 ...

  8. MQTT协议的学习

    MQTT是一个客户端服务端架构的发布/订阅模式的消息传输协议.它的设计思想是轻巧.开放.简单.规范,易于实现.这些特点使得它对很多场景来说都是很好的选择,特别是对于受限的环境如机器与机器的通信(M2M ...

  9. printf的用法进阶

    今天来好好总结一下C语言中关于printf的常用用法 基础部分 printf("%d\n", numInt); printf("%f\n", numFloat) ...

  10. sougn开源,自己写的一个项目

    源代码:http://yun.baidu.com/share/link?shareid=1504480803&uk=2739888323 联系方式:1034465036@qq.com