我明白了 A。可以使用“ip route ..... table”在 linux 中维护多个路由表 b.可以使用“ip rule add iif dev table”完成对从外部网络进入的数据包的转发决策
但是,如果我想让一个用户应用程序使用特定的路由表与外界通信,除了使用“ip netns”之外,我看不到一个简单的方法。
有没有办法告诉系统使用特定路由表的“查找路由”?
我的理解是“ip 规则”仅在生成数据包后应用,但用户应用程序甚至在生成数据包之前就查询路由表,以便可以发送网关的 ARP。
最佳答案
这个有点复杂。您应该熟悉 SELinux 标签和容器。 RedHat 状态的 Docker 文档:
by default, docker creates a virtual ethernet card for each container. each container has its own routing tables and iptables. in addition to this, when you ask for specific ports to be forwarded, docker creates certain host iptables rules for you. the docker daemon itself does some of the proxying. the takeaway here is that if you map applications to containers, you provide flexibility to yourself by limiting network access on a per-application basis.
关于linux - 如何强制用户应用程序使用特定路由表解析 "route lookup",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36163673/