如何编写一个Linux内核模块来修改数据包的源MAC地址?

我想编写一个Linux内核模块来修改将从我的计算机发送的数据包的源MAC地址。

我尝试在Netfilter上插入NF_INET_POST_ROUTING钩子,但是它只能处理L3(IP)标头。

我期待L2(MAC)钩子功能。

dingweiqiang 回答:如何编写一个Linux内核模块来修改数据包的源MAC地址?

顾名思义,NF_INET_POST_ROUTINGINET层的钩子。我认为您需要居住在NF_BR_POST_ROUTINGsource)中的netfilter_bridge.h

/* 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
本文链接:https://www.f2er.com/1380358.html

大家都在问