[Short Tip] dnsmasq and /etc/hosts


In case you do simple network tests with KVM virtual machines on your host, you might want to add some host names and IPs to /etc/hosts. However, that may not work: KVM, or better said libvirt ignores the entries in /etc/hosts. That is due to the fact that dnsmasq reads the entries of the file once: at startup. So you need to restart dnsmasq, or simply send it the SIGHUP signal:

killall -HUP dnsmasq

2 thoughts on “[Short Tip] dnsmasq and /etc/hosts”

  1. I always wondered who really wants/needs DNSmasq. In my experience it only creates problems (like this one here, but also for other files like resolv.conf etc.)
    It’s the first thing (along with nscd) that I disable on every install

  2. @Michael Drüing
    Think of such a case: you have a few OpenVPN connections from your laptop to remote sites and want that sites’ local hostnames to be resolved. In dnsmasq you can set different DNS upstream servers for a set of domains. And caching is another advantage here. This way is how I use it everyday, really a gift from heavens.

    Or think you need to share your Internet connection quickly, providing DNS proxy and DHCP server. Simple and quick, no manual studying required.

    I’ve used dnsmasq for both DHCP and DNS, in networks up to 120-140 hosts, without it being a performance bottleneck. Also heard of much larger deployments. So it’s a universal tool.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: