http://mydf.github.io/blog/ubuntu-dnsmasq/

sudo apt-get install dnsmasq
sudo vi /etc/NetworkManager/NetworkManager.conf
注释#dns=dnsmasq
sudo vi /etc/dhcp/dhclient.conf
去掉注释prepend domain-name-servers 127.0.0.1;
sudo vi /etc/default/dnsmasq
去掉注释IGNORE_RESOLVCONF=yes
sudo vi /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq
sudo service dnsmasq restart
sudo service network-manager restart