如何编写 linux 内核模块来修改数据包的源 MAC 地址?
How to write a linux kernel module to modify source MAC address of a packet?
我想编写一个 Linux 内核模块来修改将从我的计算机发送的数据包的源 MAC 地址。
我已经尝试 Netfilter
hook at NF_INET_POST_ROUTING
,但它只能处理 L3(IP) header。
我很期待 L2(MAC) 挂钩功能。
顾名思义,NF_INET_POST_ROUTING
是一个 INET
层挂钩。我认为您需要 NF_BR_POST_ROUTING
,它位于 netfilter_bridge.h
(source):
/* Bridge Hooks */
/* After promisc drops, checksum checks. */
#define NF_BR_PRE_ROUTING 0
/* If the packet is destined for this box. */
#define NF_BR_LOCAL_IN 1
/* If the packet is destined for another interface. */
#define NF_BR_FORWARD 2
/* Packets coming from a local process. */
#define NF_BR_LOCAL_OUT 3
/* Packets about to hit the wire. */
#define NF_BR_POST_ROUTING 4
我想编写一个 Linux 内核模块来修改将从我的计算机发送的数据包的源 MAC 地址。
我已经尝试 Netfilter
hook at NF_INET_POST_ROUTING
,但它只能处理 L3(IP) header。
我很期待 L2(MAC) 挂钩功能。
顾名思义,NF_INET_POST_ROUTING
是一个 INET
层挂钩。我认为您需要 NF_BR_POST_ROUTING
,它位于 netfilter_bridge.h
(source):
/* Bridge Hooks */
/* After promisc drops, checksum checks. */
#define NF_BR_PRE_ROUTING 0
/* If the packet is destined for this box. */
#define NF_BR_LOCAL_IN 1
/* If the packet is destined for another interface. */
#define NF_BR_FORWARD 2
/* Packets coming from a local process. */
#define NF_BR_LOCAL_OUT 3
/* Packets about to hit the wire. */
#define NF_BR_POST_ROUTING 4