如何将数据包重新注入到Iptables中?
我在数据包内有一个数据包,又称为隧道。所以它的形式是[IP HEADER 1][IP HEADER 2][PAYLOAD]。读取第一个标头(由库完成)后,我将在 iptables 的 INPUT 链上获取带有 [ IP HEADER 2] 的数据包。我想将数据包重新注入到 iptables 的开头,即 PREROUTING 链中。最终目标是将数据包转发到远程主机(这就是为什么我希望数据包位于 PREROUTING 链中)。我读过一些关于 libipq 的内容,但我不太确定这是最好的方法。
I have a packet inside a packet a.k.a tunneling. So it's of the form [IP HEADER 1][IP HEADER 2][PAYLOAD]. After reading the first header(done by a library) I will get the packet with [ IP HEADER 2] at the INPUT chain of the iptables. I want to re-inject the packet to the starting of the iptables i.e. in the PREROUTING chain. Ultimate aim is to forward the packet to a remote host (that's why I want the packet to be in the PREROUTING chain). I have read something about the libipq but I am not really sure that it is the best way to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管可能有一些附加目标可以做到这一点。我的直觉是,您可以使用
MARK
目标来标记此数据包,然后使用iproute2
设置您想要它去的地方的路由。类似于:
ip Rule add fwmark 0xAA table Reroute_Tunnel
然后由您添加并决定
Reroute_Tunnel
表的作用Although there may be some add-on target to do this. My gut feeling is that you would use the
MARK
target to mark this packet then useiproute2
to set up the routing of where you want it to go.Something like:
ip rule add fwmark 0xAA table Reroute_Tunnel
Then it's up to you to add and decide what the
Reroute_Tunnel
table does