Reputation: 71
I would like to emulate arrival of traffic on a specific interface (e.g. eth0). I have quite strict requirements (and quite possibly this is not possible):
To provide some context, I need the packets that I am sending to traverse the ip chain (specificlly I'm interested in netfilter hooks) exactly as if arriving on the defined interface. For example, if a rule exists in the iptables in the FORWARD chain of the filter table whose acceptance rule is '-i eth0', then the rule should match any packet sent by the requested mechanism.
Upvotes: 0
Views: 80
Reputation: 3158
You'll need to create a kernel module to manually inject your packet(s) into the networking stack. The basic steps you'll need are:
struct net_device
of the device you want to spoof (see here)skb->dev
to the net_device
found in step 3netif_rx_ni(skb)
to push the packet up the stackThere is some code that does the vast majority of this at http://cdn.kerio.com/dwn/control/control-9.0.0-442/kerio-control-kipf-9.0.0-442-linux.tgz in drivers/ipf/linux/pkt.c
at line 691 (the pkt_tx_rx_eth
function). You can also see how the kernel TUN driver does it here.
Hope this helps! best of luck.
Upvotes: 1