dnsmasq – use with Network Manager.

Niles Machine Company
Niles Machine Company (Photo credits: roadtrafficsigns.com)


Well if you have not heard about dnsmasq:


Dnsmasq is lightweight, easy to configure DNS forwarder and DHCP server.
It is designed to provide DNS and, optionally, DHCP, to a small network.
It can serve the names of local machines which are not in the global
DNS. The DHCP server integrates with the DNS server and allows machines
with DHCP-allocated addresses to appear in the DNS with names configured
either in each host or in a central configuration file. Dnsmasq supports
static and dynamic DHCP leases and BOOTP for network booting of diskless


and for the installation :


sudo yum install dnsmasq


So, now that it is installed, all you need to do is add the following in file: /etc/NetworkManager/NetworkManager.conf




in the main section. Restart your network manager using sysctl and you should see that command:


dig google.com


should show result like below:


google.com. 185 IN A
google.com. 185 IN A
google.com. 185 IN A
google.com. 185 IN A
;; Query time: 50 msec
;; WHEN: Mon Jan 14 17:16:39 2013
;; MSG SIZE rcvd: 215


If it does not, then you might want to add a dispatcher to Network Manager that adds localhost to your “/etc/resolv.conf” file. And here is the name of the file – /etc/NetworkManager/dispatcher.d/localhost-prepend and the contents


# Prepend localhost to resolv.conf for dnsmasq

if [[ ! $(grep /etc/resolv.conf) ]]; then
  sed -i '1s|^|nameserver|' /etc/resolv.conf


Thats all there is to it 🙂



Enhanced by Zemanta

OpenDNS and Proxies: Putting it All Together on Ubuntu Karmic

Image via Wikipedia

I’ve been running Ubuntu as my laptop operating system for quite some time (year or more) and find it to be quite wonderful. However, recently I had some nasty times getting everything to work with OpenDNS.

The easy thing to do is change /etc/resolv.conf to contain the OpenDNS entries. However, this was complicated by my use of polipo (web cache), pdnsd (DNS cache), and resolvconf (a resolv.conf file manager) – not to mention the use of ddclient to update the dynamic IP on the laptop, and the Gnome NetworkManager.

[link to original | source: UNIX Administratosphere