为什么我无法从 Windows 上的 Unix 机器 ping 数据库?

为什么我无法从 Windows 上的 Unix 机器 ping 数据库?

我有一台 Windows 机器,上面装有 ubuntu,我在机器上运行 docker,其中有一个容器需要连接到数据库。但问题已经出现在 Windows 和 ubuntu 之间。

如果我从 Windows ping 数据库,它会回答。

如果我从 ubuntu ping 数据库,则不行。

我在 ubuntu 上尝试过使用和不使用代理,但都不起作用。

如果我使用 ubuntu 上的代理 curl google.com,它会回答。没有答案。

当我尝试从 Windows ping 时

ping 172.17.23.96
Pinging 172.17.23.96 with 32 bytes of data:
Reply from 172.17.23.96: bytes=32 time=21ms TTL=250
Reply from 172.17.23.96: bytes=32 time=19ms TTL=250
Reply from 172.17.23.96: bytes=32 time=18ms TTL=250
Reply from 172.17.23.96: bytes=32 time=18ms TTL=250

Ping statistics for 172.17.23.96:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 18ms, Maximum = 21ms, Average = 19ms

当我尝试使用代理从 ubuntu ping 时

$ ping 172.17.23.96
PING 172.17.23.96 (172.17.23.96) 56(84) bytes of data.
From 172.17.0.1 icmp_seq=1 Destination Host Unreachable
From 172.17.0.1 icmp_seq=2 Destination Host Unreachable
From 172.17.0.1 icmp_seq=3 Destination Host Unreachable
^C
--- 172.17.23.96 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4148ms
pipe 4

当我尝试不使用代理从 ubuntu ping 时

$ export http_proxy=
$ ping 172.17.23.96
PING 172.17.23.96 (172.17.23.96) 56(84) bytes of data.
From 172.17.0.1 icmp_seq=1 Destination Host Unreachable
From 172.17.0.1 icmp_seq=2 Destination Host Unreachable
From 172.17.0.1 icmp_seq=3 Destination Host Unreachable
^C
--- 172.17.23.96 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4147ms
pipe 4

我尝试从 ubuntu 连接到 google

$ echo $http_proxy
http://host.internal:7070

$ curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

$ export http_proxy=
$ curl http://google.com
curl: (7) Failed to connect to google.com port 80: Connection refused

以下是windows的ipconfig

ipconfig

Windows IP Configuration


Ethernet adapter Ethernet 3:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::1e9:9f33:79e7:cf08%2
   IPv4 Address. . . . . . . . . . . : 10.184.146.37
   Subnet Mask . . . . . . . . . . . : 255.255.255.255
   Default Gateway . . . . . . . . . : 10.184.146.38

Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : bansel.it

Wireless LAN adapter Local Area Connection* 9:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Mobile Broadband adapter Cellular:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Ethernet 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : station
   Link-local IPv6 Address . . . . . : fe80::d00b:62bb:1184:f88e%30
   IPv4 Address. . . . . . . . . . . : 192.168.1.14
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::1d8b:c0ca:b2f1:49e3%80
   IPv4 Address. . . . . . . . . . . : 172.25.160.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :


这是来自 ubuntu

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 82:57:4f:bf:b8:64 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 2a:bd:b5:2f:cd:1c brd ff:ff:ff:ff:ff:ff
4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:14:3b:eb brd ff:ff:ff:ff:ff:ff
    inet 172.25.173.123/20 brd 172.25.175.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe14:3beb/64 scope link
       valid_lft forever preferred_lft forever
7: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 02:50:00:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.67.3/24 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::50:ff:fe00:1/64 scope link
       valid_lft forever preferred_lft forever
8: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:19:24:aa:7d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:19ff:fe24:aa7d/64 scope link
       valid_lft forever preferred_lft forever
14: vethe8ad906@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether fe:88:c4:c3:06:d1 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::fc88:c4ff:fec3:6d1/64 scope link
       valid_lft forever preferred_lft forever

答案1

我!经过多次尝试,我做到了

 wsl --unregister wsl-vpnkit

然后,下载并重新安装,

 wsl --import wsl-vpnkit $env:USERPROFILE\wsl-vpnkit wsl-vpnkit.tar.gz --version 2

而且它成功了!

相关内容