[Dnsmasq-discuss] The simplest setup to preserve IPs

Simon Kelley simon at thekelleys.org.uk
Tue Apr 1 19:58:04 BST 2008

Michal Sawicz wrote:
> Hi, I'm trying to get dnsmasq to give IPs assigned in /etc/hosts based
> on hostname from the dhcp request, my config is as follows:
> domain-needed
> bogus-priv
> filterwin2k
> listen-address=
> bind-interfaces
> expand-hosts
> domain=sawicz.net
> dhcp-range=,,12h
> dhcp-option=42,
> Based on that setup I thought that all the machines reporting a known
> hostname in the dhcp request would get the IP assigned to it
> in /etc/hosts file regardless of their IP (and, ideally, of the IP being
> leased - so that I'd be able to use either of my network ifaces).
> Unfortunately it doesn't work like that for all my hosts - it does for
> those that are windows based, and not for the others.
> For the others it assigns an IP from the dhcp-range and complains about
> not being able to assign the hostname, because it's present
> in /etc/hosts and has different IP assigned.
> Am I missing something?

The /etc/hosts entries will not, by themselves, be used to allocate 
fixed IP addresses to DHCP clients.

It's fine to put    somename

in /etc/hosts, and then just put


in /etc/dnsmasq.conf

_as_long_as_ a hostname has only one address in /etc/hosts.

I think you are implying that your DHCP clients can turn up on more than 
one network: If so, don't use /etc/hosts at all, and do


That gives dnsmasq the ability to pick the address on the correct 
subnet, and adjust the view in DNS accordingly.



> ------------------------------------------------------------------------
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

More information about the Dnsmasq-discuss mailing list