无法从docker容器ping主机

时间:2020-02-03 12:36:12

标签: docker networking containers

我已经为此工作了一个多星期,无法找到解决方案。渴望获得帮助

  1. 我有2个主机,host1和host2。

主机1的网络详细信息。

-bash-4.2 $ / sbin / ifconfig

docker0:

    flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
    inet6 fe80::42:51ff:fe23:53d7  prefixlen 64  scopeid 0x20<link>
    ether 02:42:51:23:53:d7  txqueuelen 0  (Ethernet)
    RX packets 873  bytes 218751 (213.6 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 532  bytes 86121 (84.1 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:

    flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
    inet 10.40.89.167  netmask 255.255.248.0  broadcast 10.40.95.255
    inet6 2606:b400:c13:e03:f816:3eff:fe48:f5d  prefixlen 64  scopeid 0x0<global>
    inet6 fe80::f816:3eff:fe48:f5d  prefixlen 64  scopeid 0x20<link>
    ether fa:16:3e:48:0f:5d  txqueuelen 1000  (Ethernet)
    RX packets 156003879  bytes 37924713148 (35.3 GiB)
    RX errors 0  dropped 17  overruns 0  frame 0
    TX packets 8377241  bytes 1139655340 (1.0 GiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo:

    flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1000  (Local Loopback)
    RX packets 128401  bytes 29691788 (28.3 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 128401  bytes 29691788 (28.3 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth0313598:

    flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet6 fe80::88f8:2fff:fe15:e7c7  prefixlen 64  scopeid 0x20<link>
    ether 8a:f8:2f:15:e7:c7  txqueuelen 0  (Ethernet)
    RX packets 365  bytes 190333 (185.8 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 884  bytes 191667 (187.1 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

主机2的网络详细信息

docker0:

    flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
    ether 02:42:e6:0d:4c:a6  txqueuelen 0  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:

    flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
    inet 10.40.67.187  netmask 255.255.248.0  broadcast 10.40.71.255
    inet6 fe80::f816:3eff:fe0b:cdb7  prefixlen 64  scopeid 0x20<link>
    inet6 2606:b400:c13:e00:f816:3eff:fe0b:cdb7  prefixlen 64  scopeid 0x0<global>
    ether fa:16:3e:0b:cd:b7  txqueuelen 1000  (Ethernet)
    RX packets 206797690  bytes 42338336490 (39.4 GiB)
    RX errors 0  dropped 6  overruns 0  frame 0
    TX packets 6772819  bytes 1007703663 (961.0 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo:

    flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1000  (Local Loopback)
    RX packets 133640  bytes 30800694 (29.3 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 133640  bytes 30800694 (29.3 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

问题说明:

  1. 我在 host1 中有一个运行Oracle 19c企业版的docker容器。我可以使用主机的4521端口到容器的1521端口从外部连接到该数据库。
  2. 我能够从 Oracle容器
  3. ping host1

[oracle @ b1d3ef32e104〜] $ ping -c 2 10.40.89.167

    PING 10.40.89.167 (10.40.89.167) 56(84) bytes of data.
    64 bytes from 10.40.89.167: icmp_seq=1 ttl=64 time=0.081 ms
    64 bytes from 10.40.89.167: icmp_seq=2 ttl=64 time=0.090 ms
    --- 10.40.89.167 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1043ms
    rtt min/avg/max/mdev = 0.081/0.085/0.090/0.010 ms
  1. 我能够从host1 ping主机2

-bash-4.2 $ ping -c 2 10.40.67.187

    PING 10.40.67.187 (10.40.67.187) 56(84) bytes of data.
    64 bytes from 10.40.67.187: icmp_seq=1 ttl=62 time=0.320 ms
    64 bytes from 10.40.67.187: icmp_seq=2 ttl=62 time=0.478 ms
    --- 10.40.67.187 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1005ms
    rtt min/avg/max/mdev = 0.320/0.399/0.478/0.079 ms
  1. 实际问题:我无法从 Oracle容器
  2. ping host2

[oracle @ b1d3ef32e104〜] $ ping -c 2 10.40.67.187

    PING 10.40.67.187 (10.40.67.187) 56(84) bytes of data.
    ^C
    --- 10.40.67.187 ping statistics ---
    2 packets transmitted, 0 received, 100% packet loss, time 1023ms

我正在使用默认的docker bridge网络。默认情况下,firewalld在两台主机上均运行。 host1拥有4521端口开放用于连接数据库

0 个答案:

没有答案