Linux – Ping works only with IP addresses (not with domain names)

arch linuxdnsnetworkingping

I assume this issue is to do with my DNS server, but I can't seem to figure it out. I am running Arch inside a Hyper-V virtual machine which is set up with a "Legacy Network Adapter" to my host's wireless network adapter.

When I run ping 216.58.192.164, an IP address for www.google.com, I get the following output and a successful ping (as expected):

PING 216.58.192.164(216.58.192.164) 56(84) bytes of data.

When I run ping www.google.com, I get the following output and 100% packet loss:

Ping www.google.com(ord36s01-in-x04.ie100.net (2607::f8bo::4009::80c::2004)) 56 data bytes

The internet connection on my host PC (running Windows 10) works just fine.

I have also noticed that the host PC has a different DNS server set. It is using Google's 8.8.8.8 and 8.8.4.4, while the Arch virtual machine is using my ISP's (Time Warner Cable). However, even when I change to the Google DNS servers, the issue persists.

Any help would be greatly appreciated.

EDIT:

When I run ping 8.8.8.8, I get the following output and a successful ping:

PING 8.8.8.8(8.8.8.8) 56(84) bytes of data

When I run nslookup stackexchange.com 8.8.8.8, I get the following:

Server:        8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   stackexchange.com
Address: 151.101.1.69
Name:   stackexchange.com
Address: 151.101.65.69
Name:   stackexchange.com
Address: 151.101.129.69
Name:   stackexchange.com
Address: 151.101.193.69

Best Answer

I have worked this out using Rui F Ribeiro's answer here.

I opened /etc/gai.conf and added the following to the last line:

precedence ::ffff:0:0/96 100

I then created a file at /etc/sysctl.conf and added net.ipv6.conf.all.disable_ipv6=1 to the last line. I then ran sudo sysctl -p. Then everything worked perfectly.

Related Question