Santanicoz
Posts: 4
Joined: Fri Jun 15, 2018 12:58 am

Can't connect to domain name, but with IPv4 it works

Fri Jun 15, 2018 2:01 am

Hi,

I recently bought a Raspberry Pi 3 B+ and it works just fine except that I can't connect to websites with their domain name, meaning that I can't download data with the terminal like "sudo apt-get update". For instance,

Code: Select all

ping google.com
gives
Image
but if I use the IP address of the website or force it to IPv4 it will work

Code: Select all

ping -4 google.com
Image

The thing is that I want to download packages to enjoy the beauty of the Pi but I can't, the "connecting" get stuck at 0%. For example,

Code: Select all

sudo apt-get update
gives
Image

At first, I thought that it was a DNS problem but I made so much researches that now I'm not so sure, that's why I'm here :)
I will give you my resolve.conf, interfaces file, hosts file and ifconfig, maybe it will help
/etc/resolv.conf
Image
/etc/network/interfaces
Image
/etc/hosts
Image

Code: Select all

ifconfig -a
Image

I appreciate any help in advance,
Santanicoz
Attachments
googleIPV6.PNG
googleIPV6.PNG (6.84 KiB) Viewed 406 times

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Can't connect to domain name, but with IPv4 it works

Fri Jun 15, 2018 11:37 am

I don't see any of your files. If your ping works with an IP and doesn't with a domain name, it is most certainly a dns problem.

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: Can't connect to domain name, but with IPv4 it works

Fri Jun 15, 2018 12:16 pm

Hi,
Internet is moving to IPv6, and it cause some problems if you not have IPv6 connectivity.
IPv6 stack is present even if you not have a IPv6 connection to internet, and IPv6 have preference.
To mitigate this IPv6 issues:
Not configure IPv6 on network interfaces (inclusive lo)
Disable IPv6 on kernel.
Instruct libc to prefer IPv4.

Code: Select all

On /etc/network/interfaces add these lines
iface lo inet6 manual
iface eth0 inet6 manual
iface wlan0 inet6 manual

on /etc/sysctl.conf add/change
net.ipv6.conf.all.disable_ipv6=1

on /etc/gai.conf add or change
precedence ::ffff:0:0/96  100


Santanicoz
Posts: 4
Joined: Fri Jun 15, 2018 12:58 am

Re: Can't connect to domain name, but with IPv4 it works

Fri Jun 15, 2018 3:25 pm

PROBLEM SOLVED
pksato wrote:
Fri Jun 15, 2018 12:16 pm

Code: Select all

On /etc/network/interfaces add these lines
iface lo inet6 manual
iface eth0 inet6 manual
iface wlan0 inet6 manual

on /etc/sysctl.conf add/change
net.ipv6.conf.all.disable_ipv6=1

on /etc/gai.conf add or change
precedence ::ffff:0:0/96  100

Hi,
I'm sorry for the missing files, I had problem with adding attachements.

Adding these lines solved my problem, I can't thank you enough! It was a IP preference problem after all and not DNS ;)

Return to “Troubleshooting”