I have a fresh install of Ubuntu 16.04.1 LTS (I don't think this matters, but I did apt install ubuntu-gnome-desktop after the initial install) and I have inexplicable problems with DNS resolution and after piles of searching I haven't seen this exact problem described anywhere. After the OS boots, resumes, or changes network, DNS resolution does work, but only for simple commands like ping and nslookup. Most other services like curl, ssh, and web browsers like chrome or firefox fail entirely (that is, time out without successfully resolving the host name). Here's an example.
Ping and nslookup both work:
root@myhostname:/etc/avahi# nslookup github.com
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: github.com
Address: 192.30.253.112
Name: github.com
Address: 192.30.253.113
root@myhostname:/etc/avahi# ping github.com
PING github.com (192.30.253.112) 56(84) bytes of data.
64 bytes from 192.30.253.112: icmp_seq=1 ttl=55 time=21.5 ms
64 bytes from 192.30.253.112: icmp_seq=2 ttl=55 time=28.0 ms
^C
--- github.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 21.527/24.797/28.068/3.274 ms
But if I curl immediately after it fails:
root@myhostname:/etc/avahi# curl github.com
curl: (6) Could not resolve host: github.com
I've disabled dnsmasq in NetworkManager. I've tried disabling IPV6. I've tried various changes I've read online regarding avahi settings. All to no avail. One poster went so far as to say "systemd is a mess, you're best off to just reinstall until you get it working".
Here's the kicker, though. Some time later if I leave it alone, it does start to work. Maybe 5-15 minutes later everything magically works. Does anybody have any idea how to resolve this? Thank you.