Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My dnsmasq is configured:

  • On host 'rtfm.lan'
  • Domain 'lan'
  • There are some DHCP presets that include hostnames

All '*.lan' hosts registered via DHCP do resolve fine: dnsmasq known which IPs are assigned to which hostnames. However, 'rtfm.lan' is read from /etc/hosts and resolve to

I can prevent dnsmasq from reading /etc/hosts and add an address manually:


But this is not flexible: if one day I decide to change my IP — i'll also have to change it in dnsmasq.conf.

How can I tell dnsmasq to use local-hostname with its real IP?

Just in case.. here's my DNSmasq config:

# Never forward plain names (without a dot or domain part)
# Never forward addresses in the non-routed address spaces.
# Read resolv.conf serially

#==========[ NAMESERVER ]==========#

# Cache size
# Don't read /etc/hosts
# Read additional hosts-file (not only /etc/hosts) to add entries into DNS
# Auto-append <domain> to simple entries in hosts-file

address=/localhost/ # *.localhost =>

#==========[ DHCP ]==========#
# Enable for the local network?
# Tell MS Windows to release a lease on shutdown

#=== DHCP
# Domain name
# DNS-resolve hosts in these domains ONLY from /etc/hosts && DHCP leases

# DHCP range & lease time
# Default route

dhcp-host=00:23:54:5d:27:fa,                    rtfm.lan,     
dhcp-host=00:23:54:5d:27:fb,                    rtfm.lan,     
dhcp-host=c8:0a:a9:45:f1:03, 00:1e:64:9e:e9:5e, wtf.lan,      
share|improve this question
up vote 7 down vote accepted

Normally, you would define your static hosts in /etc/hosts and enable hosts in your dnsmasq.conf file. dnsmasq allows you to specify an alternate name for this file.

If you want rtfm.lan to be addressed as then add a line reading rtfm.lan to /etc/hosts. Normally, your hosts file for dnsmasq should be portable to all your servers.

On rtfm.lan the IP stack will short-circuit the routing and not send traffic onto the network.

If you update your /etc/hosts file and signal dnsmasq with a HUP signal, the hosts file will be reread and changes applied.

EDIT: dnsmasq is not designed to serve up a dynamic host address for its own host. As noted it does serve up names from its lease file for DHCP clients.

If your host is an Internet gateway, it would normally serve a local static address. Serving up the Internet gateway address may cause routing and firewall issues.

You could configure your DHCP client to write a one line hosts file. The dnsmasq option addn-host can be used to get dnsmasq to read this file in addition to /etc/hosts. If the address is likely to change, then the DHCP client could rewrite the file and send dnsmasq a HUP signal on IP address change.

share|improve this answer
So.. there's no way to make dnsmasq use the current IP fetched from the interface? – kolypto Mar 22 '11 at 21:31
Not by default, but you can get your DHCP client to provide the required data. I am not sure why you would be serving a dynamic address for the host from dnsmasq. – BillThor Mar 22 '11 at 21:51

dnsmasq can resolve its own hostname by disabling reading from /etc/hosts and configuring another config file for reading the hostnames including itself.

dnsmasq configuration (/etc/dnsmaq.conf):


In /etc/dnsmasq_hosts, configure own hostname point to ip address one needs (as well other hostnames in local lan).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.