3

Spent a lot of time googling for the problem but did not found answer for it.

Given: fresh Ubuntu 16.04 installation, which implies IPv6 is enabled and network-manager service is using dnsmasq for local DNS caching.

The problem is that for particular domains command line utilities are not resolving host name.

$ curl -v https://deb.nodesource.com/
* Could not resolve host: deb.nodesource.com
* Closing connection 0
curl: (6) Could not resolve host: deb.nodesource.com

$ wget http://deb.nodesource.com/
--2017-04-10 15:23:34--  http://deb.nodesource.com/
Resolving deb.nodesource.com (deb.nodesource.com)... failed: Name or service not known.
wget: unable to resolve host address ‘deb.nodesource.com’

$ ssh deb.nodesource.com
ssh: Could not resolve hostname deb.nodesource.com: Name or service not known

While other "common" hosts are working well.

$ curl http://www.google.com/
<HTML>...</HTML>

Also local DNS cache is working correctly.

$ dig deb.nodesource.com   
; <<>> DiG 9.10.3-P4-Ubuntu <<>> deb.nodesource.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55668
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 13, ADDITIONAL: 12    
<...>
;; ANSWER SECTION:
deb.nodesource.com. 101 IN  CNAME   d2buw04m05mirl.cloudfront.net.
d2buw04m05mirl.cloudfront.net. 59 IN    A   54.192.98.17
<...>
;; Query time: 38 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Mon Apr 10 15:28:57 EEST 2017
;; MSG SIZE  rcvd: 615

$ dig AAAA deb.nodesource.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> AAAA deb.nodesource.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52753
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 13, ADDITIONAL: 12
<...>
;; ANSWER SECTION:
deb.nodesource.com. 300 IN  CNAME   d2buw04m05mirl.cloudfront.net.
d2buw04m05mirl.cloudfront.net. 60 IN    AAAA    2600:9000:203b:9200:1f:6523:6040:93a1
<...>
;; Query time: 58 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Mon Apr 10 15:32:53 EEST 2017
;; MSG SIZE  rcvd: 711

IPv6 requests are also working:

$ dig -6 deb.nodesource.com    
; <<>> DiG 9.10.3-P4-Ubuntu <<>> -6 deb.nodesource.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5056
;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 13, ADDITIONAL: 12
<...>
;; ANSWER SECTION:
deb.nodesource.com. 290 IN  CNAME   d2buw04m05mirl.cloudfront.net.
d2buw04m05mirl.cloudfront.net. 60 IN    A   54.192.229.174
<...>
;; Query time: 21 msec
;; SERVER: ::1#53(::1)
;; WHEN: Mon Apr 10 16:05:52 EEST 2017
;; MSG SIZE  rcvd: 615

The trick is that if I enforce IPv4 for curl or wget, then it does the trick.

$ curl -4 http://deb.nodesource.com/
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

$ wget -4 http://deb.nodesource.com/
--2017-04-10 15:40:28--  http://deb.nodesource.com/
Resolving deb.nodesource.com (deb.nodesource.com)... 54.192.98.73, 54.192.98.106, 54.192.98.122, ...
Connecting to deb.nodesource.com (deb.nodesource.com)|54.192.98.73|:80... connected.
<...>
2017-04-10 15:40:29 (175 KB/s) - ‘index.html.1’ saved [83983]

As you can see, local DNS cache supports both IPv4 and IPv6 requests and returns valid answers as well. But I don't understand what prevents all these command line utilities from resolving the host, event if by default system tries to work on IPv6.

Some proposals I found so far:

I would be thankful for any help how to get these features working together.

Thanks!


Relevant configs and outputs:

$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   ubuntu-host

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

nameserver 127.0.1.1

$ cat /etc/NetworkManager/NetworkManager.conf 
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

$ cat /etc/nsswitch.conf 
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

$ sudo tcpdump port 53
# curl -4 request
15:55:27.161321 IP 192.168.2.101.54124 > 192.168.2.1.domain: 32338+ A? deb.nodesource.com. (36)
15:55:27.184442 IP 192.168.2.1.domain > 192.168.2.101.54124: 32338 9/13/5 CNAME d2buw04m05mirl.cloudfront.net., A 54.192.229.151, A 54.192.229.174, A 54.192.229.177, A 54.192.229.185, A 54.192.229.62, A 54.192.229.76, A 54.192.229.81, A 54.192.229.98 (508)

# curl -6 request
15:57:17.283919 IP 192.168.2.101.54124 > 192.168.2.1.domain: 63423+ A? deb.nodesource.com. (36)
15:57:17.283950 IP 192.168.2.101.54124 > 192.168.2.1.domain: 4140+ AAAA? deb.nodesource.com. (36)
15:57:17.323109 IP 192.168.2.1.domain > 192.168.2.101.54124: 4140| 9/12/0 CNAME d2buw04m05mirl.cloudfront.net., AAAA 2600:9000:203b:8400:1f:6523:6040:93a1, AAAA 2600:9000:203b:da00:1f:6523:6040:93a1, AAAA 2600:9000:203b:f400:1f:6523:6040:93a1, AAAA 2600:9000:203b:2400:1f:6523:6040:93a1, AAAA 2600:9000:203b:2a00:1f:6523:6040:93a1, AAAA 2600:9000:203b:4600:1f:6523:6040:93a1, AAAA 2600:9000:203b:6000:1f:6523:6040:93a1, AAAA 2600:9000:203b:7800:1f:6523:6040:93a1 (508)
15:57:17.323132 IP 192.168.2.1.domain > 192.168.2.101.54124: 63423 9/13/5 CNAME d2buw04m05mirl.cloudfront.net., A 54.192.229.151, A 54.192.229.174, A 54.192.229.177, A 54.192.229.185, A 54.192.229.62, A 54.192.229.76, A 54.192.229.81, A 54.192.229.98 (508)
15:57:17.323683 IP 192.168.2.101.58769 > 192.168.2.1.domain: Flags [S], seq 783238377, win 29200, options [mss 1460,sackOK,TS val 4431703 ecr 0,nop,wscale 7], length 0
15:57:17.325295 IP 192.168.2.1.domain > 192.168.2.101.58769: Flags [R.], seq 0, ack 783238378, win 0, length 0
15:57:17.325933 IP 192.168.2.101.60649 > 192.168.2.1.domain: Flags [S], seq 665587122, win 29200, options [mss 1460,sackOK,TS val 4431704 ecr 0,nop,wscale 7], length 0
15:57:17.331301 IP 192.168.2.1.domain > 192.168.2.101.60649: Flags [R.], seq 0, ack 665587123, win 0, length 0
15:57:17.331540 IP 192.168.2.101.54124 > 192.168.2.1.domain: 29050+ A? deb.nodesource.com. (36)
15:57:17.331578 IP 192.168.2.101.54124 > 192.168.2.1.domain: 5852+ AAAA? deb.nodesource.com. (36)
15:57:17.334915 IP 192.168.2.1.domain > 192.168.2.101.54124: 29050 9/13/5 CNAME d2buw04m05mirl.cloudfront.net., A 54.192.229.98, A 54.192.229.151, A 54.192.229.174, A 54.192.229.177, A 54.192.229.185, A 54.192.229.62, A 54.192.229.76, A 54.192.229.81 (508)
15:57:17.334969 IP 192.168.2.1.domain > 192.168.2.101.54124: 5852| 9/12/0 CNAME d2buw04m05mirl.cloudfront.net., AAAA 2600:9000:203b:7800:1f:6523:6040:93a1, AAAA 2600:9000:203b:8400:1f:6523:6040:93a1, AAAA 2600:9000:203b:da00:1f:6523:6040:93a1, AAAA 2600:9000:203b:f400:1f:6523:6040:93a1, AAAA 2600:9000:203b:2400:1f:6523:6040:93a1, AAAA 2600:9000:203b:2a00:1f:6523:6040:93a1, AAAA 2600:9000:203b:4600:1f:6523:6040:93a1, AAAA 2600:9000:203b:6000:1f:6523:6040:93a1 (508)
15:57:17.335550 IP 192.168.2.101.38257 > 192.168.2.1.domain: Flags [S], seq 2283847070, win 29200, options [mss 1460,sackOK,TS val 4431706 ecr 0,nop,wscale 7], length 0
15:57:17.336614 IP 192.168.2.1.domain > 192.168.2.101.38257: Flags [R.], seq 0, ack 2283847071, win 0, length 0
15:57:17.336763 IP 192.168.2.101.42479 > 192.168.2.1.domain: Flags [S], seq 3878661065, win 29200, options [mss 1460,sackOK,TS val 4431707 ecr 0,nop,wscale 7], length 0
15:57:17.337800 IP 192.168.2.1.domain > 192.168.2.101.42479: Flags [R.], seq 0, ack 3878661066, win 0, length 0

1 Answer 1

1

Finally found the root cause of the problem: it is my WiFi router.

Despite the fact that dig works fine, for some reason command line utilities which are using getaddrinfo are not able to parse router's DNS answer (which in my case were proxied by dnsmasq).

I have pointed dnsmasq to DNS server of my ISP directly, and it worked fine. For some reason my router is corrupting DNS answers it gets from upstream servers.

curl --> dnsmasq -X-> router --> ISP --> ... # NOK
curl --> dnsmasq --> ISP --> ...             # OK
1
  • Just an aside I had problems with all websites except google last night after downgrading r8169 driver to r8168 and had to reconfigure IPv4 to automatic DHCP. Apr 11, 2017 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .