我的泊坞主机没有直接上网功能。它位于虚拟路由器后面。我已经在路由表中添加了一条静态路由以连接到外部。
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.114.49.128 * 255.255.255.192 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
172.17.0.0 * 255.255.0.0 U 0 0 0 docker0
10.0.0.0 10.114.49.129 255.0.0.0 UG 0 0 0 eth0
default 10.114.49.140 0.0.0.0 UG 0 0 0 eth0
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 06:10:ce:77:e1:11 brd ff:ff:ff:ff:ff:ff
inet 10.114.49.137/26 brd 10.114.49.191 scope global eth0
inet6 fe80::410:ceff:fe77:e111/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
link/ether 52:7e:b0:0c:19:1d brd ff:ff:ff:ff:ff:ff
inet 172.17.42.1/16 scope global docker0
inet6 fe80::44d4:8fff:fec4:7c4a/64 scope link
valid_lft forever preferred_lft forever
10.114.49.140
是网关地址。
当我启动一个docker容器时,容器中的路由表看起来像这样。
#route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.17.0.0 * 255.255.0.0 U 0 0 0 eth0
default 172.17.42.1 0.0.0.0 UG 0 0 0 eth0
我可以ping容器内的docker主机。但无法ping通虚拟路线和外界。 如何在docker主机上配置路由表以启用来自容器的流量转发到我的网关?
感谢