自己写 Netfilter 匹配器

深入理解Netfilter Netfilter是Linux内核中的一个框架,用于进行网络数据包的过滤和操作。它提供了强大的网络数据包处理功能,使系统管理员能够在Linux系统上实施高级的网络安全策略,包括防火墙、网络地址转换(NAT)、流量控制等。Netfilter的核心是一个包过滤器,它可以在数据包通过网络协议栈的不同阶段进行处理。当数据包经过网络协议栈时,Netfilter可以检查、修改或丢弃这些数据包,从而允许管理员根据自己的需求对网络流量进行控制和管理。 阅读详情

  看了Nicolas写的netfilter写匹配器,自己尝试编译测试,发现iptables 以及内核版本升级很多数据结构和函数接口都改变了,需要做大量的修改才能运行。


运行 iptables/netfilter

1)iptables

从 ftp://ftp.netfilter.org/pub/iptables/ 下载iptables 的源码然后拷贝libipt_ipaddr.c 到 iptables-1.4.10/extensions.

拷贝ipt_ipaddr.h 到 ./include/linux/netfilter_ipv4/

然后 

$./configure 
$make && make install


2)ipaddr.ko

编译这个内核模块需用到3个文件:

ipt_ipaddr.h  ipt_ipaddr.c  Makefile



编译完内核模块之后用

$ sudo modprobe x_tables
$ sudo insmod ipaddr.ko
加载内核模块,然后iptables命令:

sudo iptables -I OUTPUT -m ipaddr --ipsrc ipaddr --ipdst  ipaddr
设置规则。

修改后的源码:

ipt_ipaddr.c :
#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/netfilter_ipv4.h>

#include <linux/netfilter_ipv4/ip_tables.h>

#include "ipt_ipaddr.h"


#define NIPQUAD(addr) \
    ((unsigned char *)&addr)[0], \
    ((unsigned char *)&addr)[1], \
    ((unsigned char *)&addr)[2], \
    ((unsigned char *)&addr)[3]


#define NF_IP_LOCAL_IN          1
#define NF_IP_LOCAL_OUT         3



static int ipt_match(const struct sk_buff *skb,struct xt_action_param *param)
{
   const struct net_device *in = param->in;
   const struct net_device *out = param->out;	
   const struct ipt_ipaddr_info *info  = param->matchinfo;

   struct iphdr *iph = ip_hdr(skb);
   printk("entered ipt_match !\n");
   printk(KERN_INFO "ipt_ipaddr: IN=%s OUT=%s TOS=0x%02X "
                    "TTL=%x SRC=%u.%u.%u.%u DST=%u.%u.%u.%u "
                    "ID=%u IPSRC=%u.%u.%u.%u IPDST=%u.%u.%u.%u\n",

                    in ? (char *)in : "", out ? (char *)out : "", iph->tos,
                    iph->ttl, NIPQUAD(iph->saddr), NIPQUAD(iph->daddr),
                    ntohs(iph->id), NIPQUAD(info->ipaddr.src), NIPQUAD(info->ipaddr.dst)
         );

   if (info->flags & IPADDR_SRC) {
      if ( (ntohl(iph->saddr) != ntohl(info->ipaddr.src)) ^ !!(info->flags & IPADDR_SRC_INV) ) {
         
         printk(KERN_NOTICE "src IP %u.%u.%u.%u is not matching %s.\n",
                            NIPQUAD(info->ipaddr.src),
                            info->flags & IPADDR_SRC_INV ? " (INV)" : "");
         return 0;
      }
   }

   if (info->flags & IPADDR_DST) {
      if ( (ntohl(iph->daddr) != ntohl(info->ipaddr.dst)) ^ !!(info->flags & IPADDR_DST_INV) )  {

         printk(KERN_NOTICE "dst IP %u.%u.%u.%u is not matching%s.\n",
                            NIPQUAD(info->ipaddr.dst),
                            info->flags & IPADDR_DST_INV ? " (INV)" : "");
         return 0;
      }
   }
   
   return 1;
}

static int ipaddr_checkentry(const struct xt_mtchk_param *param)
{
   printk("entered ipaddr_checkentry\n");
   const struct ipt_ipaddr_info *info = param->matchinfo;
   unsigned int hook_mask = param->hook_mask;
   unsigned int matchsize = param->match->matchsize;
   char tablename[XT_TABLE_MAXNAMELEN];
   const struct ipt_ip *ip = (struct ipt_ip *)param->entryinfo;		// this is specified by param->family.

   if (hook_mask & ~((1 << NF_IP_LOCAL_IN) | (1 << NF_IP_LOCAL_OUT))) {
      printk(KERN_WARNING "ipt_ipaddr: only valid with the FILTER table.\n");
      return 0;
   }

   if (matchsize != XT_ALIGN(sizeof(struct ipt_ipaddr_info))) {
      printk(KERN_ERR "ipt_ipaddr: matchsize differ, you may have forgotten to recompile me.\n");
      return 0;
   }

   strcpy(tablename,param->match->table);
   printk(KERN_INFO "ipt_ipaddr: Registered in the %s table, hook=%x, proto=%u\n",
                    tablename, hook_mask, ip->proto);

   return 1;
}

static struct xt_match ipaddr_match  = { 
        .match	= ipt_match,
	.matchsize = XT_ALIGN(sizeof(struct ipt_ipaddr_info)),	/// without this may cause invalid size 0 != 12
	.name 	= "ipaddr",
	.checkentry = ipaddr_checkentry, 
	.me 	= THIS_MODULE 
};


static int __init init(void)
{
   printk(KERN_INFO "ipt_ipaddr: init!\n");
   return xt_register_match(&ipaddr_match);
}

static void __exit fini(void)
{
   printk(KERN_INFO "ipt_ipaddr: exit!\n");
   xt_unregister_match(&ipaddr_match);
}

module_init(init);
module_exit(fini);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Nicolas Bouliane && Samuel Jean");
MODULE_DESCRIPTION("netfilter module skeleton");

ipt_ipaddr.h
#ifndef _IPT_IPADDR_H
#define _IPT_IPADDR_H


#include <linux/types.h>

#define IPADDR_SRC   0x01     /* Match source IP addr */
#define IPADDR_DST   0x02     /* Match destination IP addr */

#define IPADDR_SRC_INV  0x10  /* Negate the condition */
#define IPADDR_DST_INV  0x20  /* Negate the condition */

struct ipt_ipaddr {
   __u32 src, dst;
};

struct ipt_ipaddr_info {

   struct ipt_ipaddr ipaddr;
   
   /* Flags from above */
   __u8 flags;
   
};

#endif  


libipt_ipaddr.c:
#include <stdbool.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>

#include <iptables.h>

#include <xtables.h>
#include <linux/netfilter_ipv4/ipt_ipaddr.h>


//./configure --prefix= ./install 
/* 
 * 	./install/sbin/iptables -m ipaddr -h
 */
static void ipaddr_help(void)
{
   printf (
            "IPADDR  options:\n"
            "[!] --ipsrc <ip>\t\t The incoming ip addr matches.\n"
            "[!] --ipdst <ip>\t\t The outgoing ip addr matches.\n"
            "\n"
         );
}

static struct option ipaddr_opts[] = {
   { .name = "ipsrc",   .has_arg = 1,   .flag = 0,   .val = '1' },
   { .name = "ipdst",   .has_arg = 1,   .flag = 0,   .val = '2' },
   { .name = 0 }
};

static void ipaddr_init(struct xt_entry_match *m)
{
   /* Can't cache this 
   *nfcache |= NFC_UNKNOWN;*/
}


__be32 in_aton(const char *str)
{
	unsigned long l;
	unsigned int val;
	int i;

	l = 0;
	for (i = 0; i < 4; i++)
	{
		l <<= 8;
		if (*str != '\0')
		{
			val = 0;
			while (*str != '\0' && *str != '.' && *str != '\n')
			{
				val *= 10;
				val += *str - '0';
				str++;
			}
			l |= val;
			if (*str != '\0')
				str++;
		}
	}
	return htonl(l);
}


struct in_addr* dotted_to_addr(const char *arg)
{
	struct in_addr * p;
	p = malloc(sizeof(struct in_addr));
	printf("%x\n",p);
	p->s_addr = in_aton(arg);
	return p;	
}

static void parse_ipaddr(const char *arg, __u32 *ipaddr)
{
   struct in_addr *ip;
   printf("in parse_ipaddr arg is %s",arg);
   ip = dotted_to_addr(arg);
   if (!ip)
      xtables_error(PARAMETER_PROBLEM, "ipt_ipaddr: Bad IP address `%s'\n", arg);

   *ipaddr = ip->s_addr;
}

static int ipaddr_parse(int c, char **argv, int invert, unsigned int *flags,
                 const struct ipt_entry *entry,
                 struct ipt_entry_match **match)
{
   struct ipt_ipaddr_info *info = (struct ipt_ipaddr_info *)(*match)->data /*NULL*/;
   printf("entered ipaddr_parse\n");
   switch(c) {
      case '1':
         if (*flags & IPADDR_SRC)
            xtables_error(PARAMETER_PROBLEM, "ipt_ipaddr: Only use --ipsrc once!");
         *flags |= IPADDR_SRC;

         info->flags |= IPADDR_SRC;
         if (invert)
            info->flags |= IPADDR_SRC_INV;

         parse_ipaddr(argv[optind-1], &info->ipaddr.src);
         break;

      case '2':
         if (*flags & IPADDR_DST)
            xtables_error(PARAMETER_PROBLEM, "ipt_ipaddr: Only use --ipdst once!");
         *flags |= IPADDR_DST;

         info->flags |= IPADDR_DST;
         if (invert)
            info->flags |= IPADDR_DST_INV;

         parse_ipaddr(argv[optind-1], &info->ipaddr.dst);
         break;

      default:
         return 0;
   }

   return 1;
}

static void ipaddr_final_check(unsigned int flags)
{
   if (!flags)
      xtables_error(PARAMETER_PROBLEM, "ipt_ipaddr: Invalid parameters.");
}

/* 
 * Can't call it ipaddr, because
 * the main structure is already
 * called like that.
 */
static void print_ipaddr(__u32 *ip_addr)
{
   printf(  "%u.%u.%u.%u ", 
            ((unsigned char *)ip_addr)[0],
            ((unsigned char *)ip_addr)[1],
            ((unsigned char *)ip_addr)[2],
            ((unsigned char *)ip_addr)[3]
         );
}

static void ipaddr_print(const struct ipt_ip *ip,
                  const struct ipt_entry_match *match,
                  int numeric)
{
   const struct ipt_ipaddr_info *info = (const struct ipt_ipaddr_info *)match->data;
   printf("entered ipaddr_print\n");
   if (info->flags & IPADDR_SRC) {
         printf("src IP ");
      if (info->flags & IPADDR_SRC_INV)
         printf("! ");
      print_ipaddr((__u32 *)&info->ipaddr.src);
   }

   if (info->flags & IPADDR_DST) {
      printf("dst IP ");
      if (info->flags & IPADDR_DST_INV)
         printf("! ");
      print_ipaddr((__u32 *)&info->ipaddr.dst);
   }
}

/* 
 * iptables-saves
 */
static void ipaddr_save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
   const struct ipt_ipaddr_info *info = (const struct ipt_ipaddr_info *)match->data;
   printf("entered ipaddr_save\n");
   if (info->flags & IPADDR_SRC) {
      if (info->flags & IPADDR_SRC_INV)
         printf("! ");
      printf("--ipsrc ");
      print_ipaddr((__u32 *)&info->ipaddr.src);
   }

   if (info->flags & IPADDR_DST) {
      if (info->flags & IPADDR_DST_INV)
         printf("! ");
      printf("--ipdst ");
      print_ipaddr((__u32 *)&info->ipaddr.dst);
   }
}

static struct xtables_match ipaddr = {
    .family	     = NFPROTO_UNSPEC,
    .name            = "ipaddr",
    .version         = XTABLES_VERSION,
    .size            = XT_ALIGN(sizeof(struct ipt_ipaddr_info)),
    .userspacesize   = XT_ALIGN(sizeof(struct ipt_ipaddr_info)),
    .help            = ipaddr_help,
   /// .init            = ipaddr_init,
    .parse           = ipaddr_parse,
    .final_check     = ipaddr_final_check,
    .print           = ipaddr_print,
    .save            = ipaddr_save,
    .extra_opts      = ipaddr_opts
};

void _init(void)
{
   xtables_register_match(&ipaddr);
}



Makefile文件:
EXTRA_CFLAGS	:= -g -O2	##Debug info .
KVERS = $(shell uname -r)

ifneq ($(KERNELRELEASE),)

obj-m			= ipaddr.o

ipaddr-objs 	        := ipt_ipaddr.o
else
KDIR := /lib/modules/$(KVERS)/build

all:
	make -C $(KDIR) M=$(PWD) modules

clean:
	rm -f *.ko *.o *.mod.o *.mod.c *.order *~  *.symvers

endif




原文链接:
http://www.linuxfocus.org/ChineseGB/February2005/article367.shtml



从iptables到nftables:Linux防火墙统一框架实战指南 防火墙是网络安全的核心组件,通过定义规则集来控制网络流量的进出。其工作原理基于对数据包头部信息的匹配与状态跟踪,在协议栈的关键钩子点进行拦截决策。nftables作为Linux内核新一代防火墙框架,其技术价值在于统一了iptables、ip6tables等多个工具,通过更高效的规则编译与执行机制,显著提升了复杂规则下的处理性能。在应用场景上,它广泛适用于服务器安全加固、网关NAT配置、DDoS基础防护等网络工程实践。本文聚焦nftables的架构设计,详解其表、链、规则四层结构,并通过实战示例展示如何利用集 阅读详情

相关推荐

基于CAT的VBM和SBM计算学习笔记(二)感兴趣区(ROI)&全脑体积(TIV)

本文介绍了用cat12运算VBM前,如何抓取ROI信息;运算VBM后,如何转化ROI文件和提取全脑体积,为之后的统计分析做好准备。t=N7T8基于CAT的VBM和SBM计算学习笔记(一)VBMhttps://mp.youkuaiyun.com/mp_blog/creation/editor/140665644。

Rose9614的博客 4357

netfilter:开发一个match模块

一、说明     下图说明了Netfilter模块是如何运行的,它指出我们需要开发两个东西,一个是用户态的共享库so,一个是内核态的内核库ko。命名规则有讲究,如果模块叫Mymodules,那么内核态源代码一般命名为ipt_Mymodules.c,头文件为ipt_Mymodules.h,用户态源代码为libipt_Mymodules.c。     用户态和内核态的模块各有什么作用?用户态的

倚楼听风雨的博客 1879

宜搭,高级认证实操2,FaaS连接器指导教程

找到FaasEntry.java将如下代码整体替换,注意引包。如图所示在util下新建EDSUtil.java代码如下。回到连接器界面点击右上角测试-->测试。连接器工厂-->新建FaaS连接器。保存-->前往云IDE开发。返回如图所示代码,部署成功。

2301_80286061的博客 3342

xt_action_param/xt_match/xt_target

/** * struct xt_action_param - parameters for matches/targets * * @match: the match extension * @target: the target extention * @matchinfo: per-match data * @targetinfo: per-targ...

sidemap的博客 1167

双目相机立体匹配算法概述(含Python代码)

立体匹配任务是计算机视觉中的一个重要问题,旨在从一对具有相同场景的图像中估计每个像素的视差(disparity)。本文对现有的传统算法和深度学习算法进行了综述,以便于各位选择合适的立体匹配算法用于深度估计或三维建模。

m0_59257547的博客 8291

基于smart_rtmp直播,最简单的部署手册

版本号 添加内容 修改时间 V1.0 新建 2021年12月30日 V1.1 增加网页播放 2021年12月31日 V1.2 增加是否可以多流和测试数据 2022年1月5日 目录 一、软件储备 1.推流软件:OBS 2.服务器流媒体软件:smart_rtmp 3.播放软件:Pot...

qq_28768477的博客 1万+

linux iptables实现

Xtables提供的资源   struct  xt_af  xt[]结构数组 该数组用于挂载各个协议的match和target资源。由于写者(添加、删除)和读者(查找)都是在内核空间进程上下文执行,所以它们只需要用xt[n].mutex信号量进行互斥。读者(查找)在将规则关联上一个match或target时会增加它们所在模块的引用计数,在它释放这个引用计数之前该模块是不会被卸载的,所

godleading的专栏 5954

基于Java+SpringBoot+Vue的中小企业设备管理系统的设计与开发(源码+lw+部署文档+讲解等)

💗博主介绍:✌新人博主,工作经验两年+、专注于Java、小程序技术领域和毕业项目实战✌💗🌟文末获取源码+数据库🌟

2301_76502068的博客 1382

iptables源代码分析之主流程分析

由于我们只关注ipv4. 看程序的流程就是要从主线开始看起。 目录结构我 libiptc:iptables控制层代码 iptables:iptables主体代码 extensions:iptables扩展代码,一般是xtables_register_matches函数注册被初始化的struct xtables_match结构体 我执行的iptables命令是 iptables ...

脚踏实地,不断突破自我,每天有收获就OK 5714

用GraphPad Prism直出单细胞亚群堆叠柱状图

用GraphPad Prism直出单细胞亚群堆叠柱状图

fivehuge的博客 4195

基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的体育赛事目标检测系统(Python+PySide6界面+训练代码)

本文详细介绍了一个基于YOLOv5/v6/v7/v8的体育赛事目标检测系统的设计与实现。系统采用先进的深度学习算法,结合PySide6图形界面,实现了对体育赛事中运动员、球类、裁判等多种目标的实时检测与跟踪。本文将全面阐述系统的架构设计、算法原理、训练流程、界面实现以及实际应用效果,并提供完整的代码实现。

YOLO 509

iptables match模块扩展 数据传递(用户空间 -> 内核空间)

大致过程: 首先,通过iptables命令将使用扩展模块的相关策略添加。例如:iptables -t mangle -A OUTPUT -p icmp -m pktsiz --size 100:200 -j DROP 其次,当接收到网络数据,内核对相关协议(IPV4)相关表(mangle)相关链(OUTPUT)..扩展模块(pktsize)进行匹配,对符合规则的进行相关的动作。 实装过程: ...

sidemap的博客 1841

基于Simulink的间接功率控制的矩阵变换器

通过上述步骤,我们成功设计并实现了基于 Simulink 的间接功率控制的矩阵变换器仿真模型。该模型能够通过控制输入电流和输出电压,实现对功率的间接控制,适用于电机驱动、可再生能源系统、电力传输等领域。通过虚拟场景仿真、参数优化和性能评估,验证了系统的稳定性和高效性,并通过调整 PI 控制器参数和优化调制算法,进一步提升了系统的性能。

MHD0815的博客 295

自己写 Netfilter 匹配器【转】

<br />概述写一个 iptables/netfilter 匹配模块的大体步骤如下: 找到你要匹配的具体情况。写用于接受参数的用户空间部分程序。写用于分析包信息,得出是否匹配结论的内核空间部分程序。 1.0 iptables 模块 iptables 库的用途基本上讲就是和用户交互,它捕获用户要传送给核心态程序的参数。  1.1 可用的数据结构和函数 首先是一些基本数据结构。 <iptables/include/iptables.h><br />稍后文中就将可以看到这些结构的用途了。 /*

932

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

linux的netfilter编程相关技术文档

最近在开发网络审计相关的系统,由于涉及到抓取网络数据包的问题,故需要学习netfilter的相关知识,先将 linux的netfilter编程相关技术文档汇总如下: http://www.ibm.com/developerworks/cn/linux/network/l-netip/index.html   http://blog.chinaunix.net/u2/82249/show

星愿心愿的专栏 2261

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Linux Netfilter实现机制和扩展技术

Linux Netfilter实现机制和扩展技术    2.4.x的内核相对于2.2.x在IP协议栈部分有比较大的改动, Netfilter-iptables更是其一大特色,由于它功能强大,并且与内核完美结合,因此迅速成为Linux平台下进行网络应用扩展的主要利器,这些扩展不仅包括防火墙的实现--这只是Netfilter-iptables的基本功能--还包括各种报文处理工作(如报文加

闲云野鹤专栏 544

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Android 7系统网络(二)内核层—netfilter_iptables与路由策略

DNS 拦截是 Android 网络管理的核心机制——通过将 UDP 53 端口的流量统一重定向到 netd,Android 得以按网络接口(WiFi/移动数据/VPN)使用不同的上游 DNS 服务器,并实现统一的 DNS 缓存。:传统路由是"一条路走到黑",策略路由是"看标记选路"——fwmark 就是那个标记,内核根据它决定查询哪张路由表,从而让 WiFi 和移动数据的流量各走各的路。:MASQUERADE 是一种特殊的 SNAT——自动替换源 IP 为出口接口的 IP,是移动热点的核心技术。

AfinalStone的专栏 296

Linux技术03-Netfilter、Iptables、Nftables、Firewalld

Netfilter是Linux内核中的一个强大的网络数据包处理框架,主要用于实现防火墙、网络地址转换(NAT)等功能。它直接利用Netfilter的数据包处理机制,但在用户空间中提供了一个更现代的接口,统一了不同协议(IPv4、IPv6、ARP和桥接流量)的处理。2.数据包过滤和转发规则:管理员可以通过工具(如iptables或nftables)在用户空间定义数据包处理规则,这些规则被传递到内核空间并在钩子点处应用。连接跟踪模块是Netfilter的关键部分,帮助系统了解所有通过的网络连接的状态。

fzw1030的博客 1635

网络层SSL/TLS证书校验:基于Netfilter的公钥绑定实现

摘要:本文介绍了一种基于Linux内核Netfilter/Xtables框架的SSL/TLS证书公钥绑定技术实现方案。该技术通过在网络底层对进出服务器的流量进行强制校验,解决传统CA信任链可能被伪造的安全隐患。核心模块通过解析SSL/TLS握手包中的证书公钥,与预设值进行匹配校验,只有公钥匹配才放行数据包。文章详细阐述了整体设计思路和代码实现逻辑,包括连接状态管理、证书解析和公钥比对等关键环节,为网络安全防护提供了一种内核级解决方案。

chen1415886044的博客 912

iptables/netfilter分析和相关链接整理

iptables 内核框架 iptables 命令分析(图片版)(转) 不知道出自哪位大牛之手,实在是令人佩服 一、整体架构概述 二、相关数据结构  三、内建filter表 四、iptables命令 五、一个复杂例子 图片下载地址: http://download.youkuaiyun.com/source/2858469 结合上图参考 Linux netfilter源码

Wait for 的专栏 1399

TCP实现之:iptables原理

TCP实现之:iptables原理 一、前言 提到防火墙,大家都不陌生。防火墙技术是通过有机结合各类用于安全管理与筛选的软件和硬件设备,帮助计算机网络于其内、外网之间构建一道相对隔绝的保护屏障,以保护用户资料与信息安全性的一种技术。通俗的讲,防火墙就是计算机操作系统中的一种对网络报文进行监控、筛选和过滤以达到保护操作系统免受攻击的机制。 防火墙常用的功能包括以下几点: 包过滤功能。包过滤指的是防火墙对进入(入站)或者发出(出站)的网络数据包按照预先定义好的规则进行过滤,对于不符合规则的包进行丢弃等操作,这

qq_17045267的博客 742

linux:iptables防火墙

一,防火强概述 基本概念   Linux真正的防火墙安全框架是 netfilter ,它位于Linux的内核空间。 iptables本质是一个命令行工具,位于用户空间,它相当于一个代理,将用户的安全设定执行到对应的安全框架 netfilter 中   2. 工作方式   iiptables的工作方式是根据配置的规则去处理数据包。规则存储在内核空间的信息包过滤表中,规则里面包括了源地址,源端口,目的地址,目的端口,传输协议,应用层协议等。当数据包与规则匹配时,iptables就根据规则处理数据包,如放行(

LX199707的博客 288
上一篇: linux内核调试环境搭建-4 调试模块初始化函数
下一篇: 深入Linux网络核心堆栈--netfilter详解(整理)
xianjian_x
博客等级 码龄14年 231粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值