If you are running an Ubuntu system prior to 12.04 that hasn't yet been upgraded to 12.04 or later, or if you have removed the resolvconf package then install the resolvconf package.
sudo apt-get install resolvconf
If resolvconf was already installed, ensure that /etc/resolv.conf is a symbolic link to ../run/resolvconf/resolv.conf.
sudo dpkg-reconfigure resolvconf
Once you have installed the dnsmasq package (not to be confused with the dnsmasq-base package) you do not need to edit /etc/resolv.conf. The dnsmasq initscript causes (via resolvconf) '127.0.0.1' to be added to resolv.conf when dnsmasq starts, provided the value of
IGNORE_RESOLVCONF is not set to
yes in /etc/default/dnsmasq.
Doubters, please read /etc/init.d/dnsmasq.
P.S. In Ubuntu 12.04 there is a complicating factor. NetworkManager by default starts a dnsmasq process which listens exclusively on 127.0.0.1. This conflicts with the "standalone" dnsmasq process; only one of the two can start. This is a known bug, #959037, which was fixed in Ubuntu 12.10 (by moving NM-dnsmasq's listen address to 127.0.1.1). If you are still running Ubuntu 12.04 and you want to run standalone dnsmasq then you should either disable the NetworkManager-controlled dnsmasq (by commenting out "dns=dnsmasq" in /etc/NetworkManager/NetworkManager.conf) or configure the standalone dnsmasq not to listen on 127.0.0.1.