I have installed DNSMASQ but it was not starting as 53 port was busy.
I found out that ubuntu already had dnsmasq package and it's working.
Now the problem is...I just want to be able to resolve my hosts in /etc/hosts through it
i.e: nslookup somehostonlan localhost
to be resolved to certain IP taken from /etc/hosts file.
but this is not happening.
Why? BTW, as the caching DNS server it's working fine. I just want it to resolve hosts from /etc/hosts file that's all
To speed up internet, ubuntu 12.04 has added a plugin to NetworkManager to start dnsmasq, a local dns server that caches dns entries. The problem is the plugin has hardcoded the --no-hosts string.
So one solution is to comment out the line that load the plugin in the NetworkManager config file and restart NetworkManager :
Another solution is to wrap dnsmasq to filter out the undesired arguments:
Please mark the bug as affecting you.
Another solution without patching system files
This bug still affected me even now ( Ubuntu 14.04 ).
Finally I found a solution that, simply add this line 'addn-hosts=/etc/hosts' to dnsmasq configuration file of Newworkmanager package.
The idea is, we are adding /etc/hosts as a additional host file .
Even if I could find a solution, hard-coded option '--no-hosts' in the binary file /usr/sbin/NetworkManager disappoints me.
As of August 2015, the other answers are outdated.
Simple answer
/etc/NetworkManager/dnsmasq.d/hosts.conf
.address=/whatever/1.2.3.4
in it. See the docs (look for--address
). Wildcards are possible:address/.whatever./1.2.3.4
.dnsmasq
(bug).$ service network-manager restart
.dnsmasq should automatically use the
/etc/hosts
file. This can be disabled by the-h
command line option orno-hosts
configuration option. I would not expect either to be set in the default configuration.Try forcing dnsmasq to reload its hosts file. (Changes to the configuration file require a restart). Either of these commands should work.
If you are working with a system that has
no-hosts
specified you should be able to use theaddn-hosts
option to override it. Normally, this would be used to read an additional file in/etc/hosts
format. This can be used to specify additional host data that you want DNS to provide, but don't want in your/etc/hosts
file. This can be used to allow the package manager and related tools to manage/etc/hosts
while additional hosts data is provided in an alternate file.