0

I can't use git clone or even apt-get install because I get a "cannot resolve host" error. They were working before, but I have no idea what changed that broke the DNS resolve. I can't find any information about what's going on.

Ping:

ping google.com
ping: unknown host google.com

Telnet:

telnet google.com
telnet: could not resolve google.com/telnet: Name or service not known

NSLookup:

nslookup google.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 74.125.239.40
Name:   google.com
Address: 74.125.239.46
Name:   google.com
Address: 74.125.239.36
Name:   google.com
Address: 74.125.239.39
Name:   google.com
Address: 74.125.239.33
Name:   google.com
Address: 74.125.239.41
Name:   google.com
Address: 74.125.239.38
Name:   google.com
Address: 74.125.239.32
Name:   google.com
Address: 74.125.239.35
Name:   google.com
Address: 74.125.239.34
Name:   google.com
Address: 74.125.239.37

Host:

host google.com
google.com has address 74.125.239.38
google.com has address 74.125.239.36
google.com has address 74.125.239.39
google.com has address 74.125.239.35
google.com has address 74.125.239.32
google.com has address 74.125.239.33
google.com has address 74.125.239.40
google.com has address 74.125.239.41
google.com has address 74.125.239.34
google.com has address 74.125.239.46
google.com has address 74.125.239.37
google.com has IPv6 address 2607:f8b0:4010:801::1009
google.com mail is handled by 50 alt4.aspmx.l.google.com
google.com mail is handled by 10 aspmx.l.google.com
google.com mail is handled by 20 alt1.l.google.com
google.com mail is handled by 40 alt3.l.google.com
google.com mail is handled by 30 alt2.l.google.com

netstat -rn

Kernel IP routing table
Destination     Gateway        Genmask        Flags MSS Window irtt Iface
0.0.0.0         162.243.147.1  0.0.0.0        UG      0 0         0 eth0
162.243.147.0   0.0.0.0        255.255.255.0  U       0 0         0 eth0

/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

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

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

netgroup:       nis

Server: Ubuntu 14.04 trusty, Nginx, HHVM FastCGI

/etc/resolv.conf used to have the Google IPs (8.8.8.8 and 8.8.4.4) while it wasn't working. I say "used to" because I saw someone's solution was to reinstall resolvconf, but since I can't resolve any hostnames, it just deleted it.

I reinstalled resolv.conf and it looks normal now, but DNS is still not resolving.

/etc/resolv.conf:

nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

/etc/hosts

127.0.1.1 my-domain.tld my-domain.tld
127.0.0.1 localhost

::1 ip6-localhost 1p6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Note: I'm kind of new to Linux, but hopefully I'm not missing something obvious. This is the first time I couldn't figure out a solution to a problem by searching online.

  • 4
    what is the content of /etc/resolv.conf ? – schaiba Sep 28 '15 at 0:47
  • Your nslookup command still uses Google's 8.8.8.8 tho. – ott-- Sep 28 '15 at 20:08
  • The difference is (or was) because nslookup host dig use only DNS, directly from their own code, not the generic library calls that use multiple mechanisms per nsswitch or similar. That doesn't explain why the library calls are failing though. IME bad stuff in /etc/hosts usually gets ignored, but maybe you've got something bad enough to break it; look. I don't know what implements either kind of mdns4 in debian, but you could try temporarily taking those tokens out of nsswitch hosts: to see if that matters. – dave_thompson_085 Sep 29 '15 at 6:54
  • @dave_thompson_085 my /etc/hosts file looks pretty normal to me. It has 127.0.1.1 domain.tld domain.tld and 127.0.0.1 localhost. – That's Not Cool Sep 29 '15 at 18:42
  • Have you got a route set up for the IPv6 addresses? What about for the IPv4 one? (Can you ping or ping6 those addresses in your resolv.conf file?) What does the routing table from netstat -rn show, please? – roaima Sep 29 '15 at 19:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.