Super User is a question and answer site for computer enthusiasts and power users. 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

I've trying to get dnsmasq working as a combined dns and dhcp server. It's infuriating so far... In short, the DNS works fine for anything added to /etc/hosts, and the dhcp works fine, but the dhcp is not updating the dns with hostname information from clients.

The outcome of this is that i can only ping a node by hostname if i know it's address, which means setting a static dhcp allocation and putting the hostname into /etc/hosts manually, which is very annoying and kind of defeats the poit of dhcp. There must be a way to get dnsmasq to update the hosts file, surely

The clients aren't using fqdn's if that matters, and i think i've tried every combinination of "expand-hosts" and "domain="

following is the dnsmasq config file contents:

domain-needed
bogus-priv
except-interface=tun0

dhcp-range=192.168.1.10,192.168.1.80,255.255.255.0,12h
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-authoritative

log-queries
log-dhcp
share|improve this question
    
What kind of clients are you talking about? Some client do not send a name, or at least they do not send the name you would expect. – Zoredache Jul 20 '11 at 0:17
    
linux clients, for now i can force sending a name with dhclient -H , but that isn't seeming to fix the issue. i tried hostname and hostname.domain.com passed into -H – Sirex Jul 20 '11 at 5:20
up vote 2 down vote accepted

Try setting a domain with domain example.org.

dnsmasq also has a hook to call a script dhcp-script=foo.sh. The arguments sent to the script are "add" or "del", then the MAC address, the IP address and finally the hostname.

It should be relatively easy to quickly create a script that updates the hosts file.

share|improve this answer
    
accepting this as the answer. It turns out that a) i needed to give the fqdn in the hostname passed to the dhcp server, and b) my test 2 virtual machine clients were clashing mac addresses, which led to some obscure symptoms. Needless to say it wasn't an ideal time for a mac clash when also fighting dynamic dns. – Sirex Jul 20 '11 at 5:58

The DHCP client needs to send a name to have the name made available in the DNS. Otherwise dnsmasq can supply the name, but you have to configure that in /etc/dnsmasq.conf or /etc/hosts first.

Since dnsmasq is a DNS server, you need to have a domain name. The domain-needed part enforces that. Set a domain name in your configuration also.

So here's basically what I have:

bogus-priv
dhcp-authoritative
dhcp-host=00:0c:29:1b:62:c6,host1,192.168.1.86,infinite
dhcp-host=00:0c:29:f7:e6:7d,host2,192.168.1.89,infinite
dhcp-host=00:1e:58:94:d2:5b,192.168.1.10,infinite
dhcp-option=19,0           # option ip-forwarding off
dhcp-option=27,1
dhcp-option=42,0.0.0.0
dhcp-option=44,192.168.1.10     # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
dhcp-option=45,0.0.0.0     # netbios datagram distribution server
dhcp-option=46,8           # netbios node type
dhcp-option=6,0.0.0.0
dhcp-option-force=210,/
dhcp-option-force=211,30i
dhcp-option=option:domain-search,example.com
dhcp-option=option:router,192.168.1.1
dhcp-range=192.168.1.50,192.168.1.150,255.255.255.0,30d
domain=example.com
domain-needed
enable-tftp
expand-hosts
interface=eth0
local=/dartworks.biz/
local=/localnet/
no-poll
no-resolv
server=<ISP DNS 1>
server=<ISP DNS 2>
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .