Packet forwarding
I want to make a program to receive a packet on one network interface do some processing and forward it to a different开发者_运维知识库 interface. What can be the most efficient way to do it on Linux? I want to forward the packet with minimum delay
Use libnetfilter_queue
.
iptables <....> -j NFQUEUE --queue-num <queue number>
Then write your own program and link with libnetfilter_queue
. After some really simple operations you will be able to use recv
to receive packets and nfq_set_verdict
to decide what to do with the packet.
精彩评论