3

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

/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 mdns4_minimal dns wins [NOTFOUND=return] mdns4
networks:       files

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

netgroup:       nis

/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 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8

Server: Ubuntu 14.04 trusty, Nginx, HHVM FastCGI

route -n

Kernel IP routing table
Destination     Gateway        Genmask        Flags Metric Ref Use 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/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
  • Can you ping 8.8.8.8? What's your route settings? route -n – A.B. Sep 29 '15 at 4:54
  • @A.B. Yes, I can ping 8.8.8.8 I'll add route -n to the question. – Confused One Sep 29 '15 at 5:30
  • @ConfusedOne try the method I describe here. Basically , it involves setting custom dns with supersede domain-nameservers xxx.xxx.xxx.xx in /etc/dhcp/dhclient.conf file, where xxx.xxx.xxx.xx is ip of your desired dns server. See if that makes it work. Also, try commentding out dns=dnsmasq option in /etc/NetworkManager/NetworkManager.conf – Sergiy Kolodyazhnyy Sep 29 '15 at 6:18
  • @Serg I added supersede domain-name-servers 8.8.8.8 and then prepend domain-name-servers 8.8.8.8 but nothing changed. – Confused One Sep 29 '15 at 6:55
  • @ConfusedOne have you restarted network once you do that ? I forgot to mention that bit – Sergiy Kolodyazhnyy Sep 29 '15 at 7:20
0

Something was wrong with my IPv6 configuration, so I ended up deleting the IPv6 section of my /etc/hosts file, which got everything working.

More information can be found here: https://unix.stackexchange.com/questions/232434/why-host-and-nslookup-on-ubuntu-resolve-hostnames-while-ping-and-telnet

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.