Ping can not resolve host which has both ipv6 addresses and ipv4 addresses

Hi, I got a trouble to ping a host which has some ipv4 addresses and some ipv6 addresses. But my network only support ipv4. It seems ping is not use ipv4 address. I tested this with chrome the result is same. I think it’s a issue from OS.

My manjaro version is 20.2 and get the latest update.

Please help, thanks!

Here’s the test result

$ ping res.wx.qq.com                            
ping: res.wx.qq.com: Name or service not known

$ nslookup res.wx.qq.com                           
Server:         192.168.11.1
Address:        192.168.11.1#53

Non-authoritative answer:
res.wx.qq.com   canonical name = reswx.tc.qq.com.
reswx.tc.qq.com canonical name = res.wx.qq.com.v6.tcdn.qq.com.
res.wx.qq.com.v6.tcdn.qq.com    canonical name = res.wx.qq.com.sched.ssdv6.tdnsv6.com.
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 123.125.110.183
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 123.125.110.212
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 111.206.15.84
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:101:23::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:8719:64:2a:24::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:8719:64:2a:22::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:8720:0:7:23::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:872b:e01:7:37::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:872b:e01:8:24::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:8720:800:2:1d::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:f:2f::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:101:22::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:100:23::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:e:1e::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:872b:e02:5:12::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:f:1a::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:f:1d::
Name:   res.wx.qq.com.sched.ssdv6.tdnsv6.com
Address: 2408:80f0:4105:f:2c::

Hi and welcome to the forum :+1:

You should enablesystemd-resolved.service for commands like that:

  • sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  • And afterwards enable it’s usage with:
    systemctl enable --now systemd-networkd systemd-resolved

Thank you very much!
Chrome seems no problem now. But ping can work only first time (viz it get the ipv4 address) then it will almost hang (very very slow) when it get the ipv6 address.

For example

$ ping -6 res.wx.qq.com
PING res.wx.qq.com(2408:80f0:4105:101:23:: (2408:80f0:4105:101:23::)) 56 data bytes
64 bytes from 2408:80f0:4105:101:23:: (2408:80f0:4105:101:23::): icmp_seq=1 ttl=59 time=6.30 ms
64 bytes from 2408:80f0:4105:101:23:: (2408:80f0:4105:101:23::): icmp_seq=2 ttl=59 time=5.05 ms

The above response is very slow and it costs several minutes to print one line.

Then there is a problem with your DNS server, or you don’t have IPv6 connectivity.
(try to reboot)

The issue of the topic title seems resolved…

This might be worth a try:
Test your IPv6

Sorry for misunderstanding.
I mean both ping and ping -6 will get the ipv6 address and hang.

e.g.

$ ping res.wx.qq.com
PING res.wx.qq.com(2408:80f0:4105:f:1d:: (2408:80f0:4105:f:1d::)) 56 data bytes

Thanks for your suggestion.
Here is the result

|Test with IPv4 DNS record||ok (1.037s) using ipv4|
| --- | --- | --- |
|Test with IPv6 DNS record||ok (2.713s) using ipv6|
|Test with Dual Stack DNS record||ok (2.950s) using ipv6|
|Test for Dual Stack DNS and large packet||ok (1.367s) using ipv6|
|Test IPv6 large packet||ok (1.296s) using ipv6|
|Test if your ISP's DNS server uses IPv6||ok (1.295s) using ipv4|
|Find IPv4 Service Provider||ok (0.290s) using ipv4 ASN 4808|
|Find IPv6 Service Provider||ok (0.741s) using ipv6 ASN 4808|

Seems your IPv6 is at least partially working. Unfortunately mine isn’t with the current ISP (partially working with previous) so I can’t test those things on this connection. No pub networks to try either for a while …

I will have to try the phone tether to see if that resolves IPv6.

Also I don’t know if there is any extra configuration needed in network settings … I’ll have to look in to that.

Thank you!
Is there way to let ping (or all applications) only use ip-v4 address, not use ip-v6 address?

Either disable IPv6 in your Network settings or disable it completely with via the kernel command line.

https://wiki.archlinux.org/index.php/IPv6#Disable_IPv6

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.