Linux 命名空间网络

Linux 命名空间网络

我正在尝试允许从网络命名空间连接互联网。我尝试使用docker0基于以下规则的全局命名空间中运行的网桥执行此操作:这次谈话。如果我尝试在新的命名空间内 ping,我会收到Destination Host Unreachable一些配置不正确的信息。我对命名空间非常陌生,因此任何帮助我都非常感谢。

全局命名空间详细信息

# ifconfig -a
docker0   Link encap:Ethernet  HWaddr 02:42:99:e7:76:59
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:99ff:fee7:7659/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:215 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:6476 (6.4 KB)  TX bytes:258 (258.0 B)

eth0      Link encap:Ethernet  HWaddr 06:b1:78:7b:d4:73
          inet addr:10.178.155.11  Bcast:10.178.155.63  Mask:255.255.255.192
          inet6 addr: fe80::4b1:78ff:fe7b:d473/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
          RX packets:53259 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8750 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:68143404 (68.1 MB)  TX bytes:2471391 (2.4 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:164 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:12104 (12.1 KB)  TX bytes:12104 (12.1 KB)

veth0     Link encap:Ethernet  HWaddr 1e:cb:a7:de:42:20
          inet addr:172.17.42.3  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::1ccb:a7ff:fede:4220/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:212 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9216 (9.2 KB)  TX bytes:648 (648.0 B)

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.178.155.1    0.0.0.0         UG    0      0        0 eth0
10.178.155.0    0.0.0.0         255.255.255.192 U     0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 veth0

自定义命名空间详细信息

# ifconfig -a
eth0      Link encap:Ethernet  HWaddr ea:df:85:61:3d:76
          inet addr:172.17.1.1  Bcast:0.0.0.0  Mask:255.255.255.255
          inet6 addr: fe80::e8df:85ff:fe61:3d76/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:648 (648.0 B)  TX bytes:9216 (9.2 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:247 errors:0 dropped:0 overruns:0 frame:0
          TX packets:247 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:25620 (25.6 KB)  TX bytes:25620 (25.6 KB)

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
12: eth0@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether ea:df:85:61:3d:76 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.1.1/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::e8df:85ff:fe61:3d76/64 scope link
       valid_lft forever preferred_lft forever

# brctl show
bridge name bridge id       STP enabled interfaces
docker0     8000.024299e77659   no      veth0

相关内容