This is a very popular question, with a collection of standard possible answers, all of which, IMO, are pretty hacky. I for one have always had problems getting Ubuntu to respect the DNS settings I set up in NetworkManager -- in particular setting static DNS servers with "Automatic (DHCP) addresses only" -- and today I finally figured out what was ACTUALLY WRONG.
The problem is in the interaction between resolvconf and NetworkManager. resolvconf has this file called
/etc/resolvconf/interface-order. At least on my systems, NetworkManager isn't in this file at all (except that it's covered by the * wild card at the end). So what happens is, dhclient's most recent report to resolvconf takes precedence over anything NetworkManager has to say.
Thus, at least in my case, the actual answer was to add
at or near the top of
(Yes, I know many people just say "uninstall resolvconf", which seems like a bad idea in and of itself, to me. But more than that, at least wily and xenial consider resolvconf a vital part of the system [i.e., ubuntu-minimal depends on it], so it would be difficult to keep your system in a consistent, updated state without resolvconf.)
Upon request I can provide more detail about how I figured this out. In a nutshell, I replaced the resolvconf executable with a shell wrapper around it which dumped its arguments, input, output and stderr to files; and added set -x to resolvconf's update scripts.