DHCP Request Cycle can get caught in infinite loop

Bug #327703 reported by FactTech
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dnsmasq (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: dnsmasq

Running Xubuntu 8.10, dnsmasq 2.45-1ubuntu1...

I'm not sure what caused this, since I've been mucking about with the settings for a while now, but at the moment, I'm seeing a Windows XP laptop caught in an endless loop trying to renew its lease. From /var/log/syslog:

Feb 10 11:05:13 dhcp-server dnsmasq[19895]: DHCPDISCOVER(eth0) 11:22:33:44:55:66
Feb 10 11:05:13 dhcp-server dnsmasq[19895]: DHCPOFFER(eth0) 192.168.X.X 11:22:33:44:55:66
Feb 10 11:05:13 dhcp-server dnsmasq[19895]: DHCPREQUEST(eth0) 192.168.X.X 11:22:33:44:55:66
Feb 10 11:05:13 dhcp-server dnsmasq[19895]: DHCPNAK(eth0) 192.168.X.X 11:22:33:44:55:66 address reserved

(I've altered server name, IP address, and MAC address from real values.)

I think I should be able to fix this by stopping the dnsmasq service, editing the lease file, then restarting the dnsmasq, per some advice I saw elsewhere, but nonetheless this behavior seems strange in that a DHCPOFFER is made by the server, but when the client tries to request it, it receives a DHCPNAK message.

I have configured this particular machine to get an IP address assignment by hostname from the /etc/hosts file, which may have something to do with it. It previously obtained the lease in this manner, but after "repairing" the connection on Windows, it's stuck in this loop.

Revision history for this message
FactTech (launchpad-facttechnologies) wrote :

FYI, the stop/delete/start process worked -- lease was renewed properly. For anyone following along, in a terminal, type:

$ sudo /etc/init.d/dnsmasq stop
$ sudo nano /var/lib/misc/dnsmasq.leases
   (or whatever command you want to use to modify your lease file -- find the line with the old lease, delete it, then save the file)
$ sudo /etc/init.d/dnsmasq start

Revision history for this message
C. Cooke (ccooke) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please answer these questions:

* Is this reproducible?
* If so, what specific steps should we take to recreate this bug?

This will help us to find and resolve the problem.

C. Cooke (ccooke)
Changed in dnsmasq:
status: New → Incomplete
Revision history for this message
FactTech (launchpad-facttechnologies) wrote :

I think the way it occurred was that I had a dual-boot machine (WinXP/Ubuntu 8.04) that had originally signed up for the lease under Windows, then was shut off and booted into Linux, where it couldn't connect, then booted back into Windows, where I observed the issue while diagnosing.

The option had not yet been set to instruct Windows machines to drop the lease when shutting down, so it may simply have been that the lease was still active. It does not seem to be happening now -- booting in either mode gets the desired assignment.

I don't really want to attempt to reproduce it since I have everything working the way I want it to now, but I wanted to report this since the DHCP dialogue seemed strange. If I find a way to reproduce it, I will report back.

Revision history for this message
FactTech (launchpad-facttechnologies) wrote :

FYI -- I'm seeing a repeat of this behavior under slightly different circumstances. In this case, I have a machine that was set up with Ubuntu 8.04 and was issued a lease. I rebooted the machine with an install disk for another distribution (it's Fluxbuntu 7.10 RC, which uses the 'alternate' text-based install type). When the installation gets to network autoconfiguration, it fails, and I see the same DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPNAK cycle as described originally.

Once again, there is an existing entry in the leases file associated with the MAC address for this machine's network card, which seems to be part of the problem. Perhaps it's the combination of parameters I've fed to dnsmasq?

The conf file has an entry:

  dhcp-host=foo

which, as I understand it, tells it to check /etc/hosts to get a standard IP assignment. In /etc/hosts, there's:

 192.168.X.X foo

only with real numbers instead of Xs, obviously. Currently in the leases file, there's a line:

  1234411797 11:22:33:44:55:66 192.168.X.X foo *

only with the real MAC address and IP, obviously.

I have a hunch that the cause is something like this:

 1. dnsmasq gets DHCPDISCOVER packet
 2. dnsmasq looks at originating MAC and checks leases file to see if it's in there
 3. dnsmasq finds line with same MAC and issues DHCPOFFER with associated IP address from lease file
 4. client does what's expected and makes DHCPREQUEST with that IP
 5. dnsmasq now takes a look at the client's machine name, and sees that the requested address is "reserved" for that name per /etc/hosts
 6. dnsmasq replies with DHCPNAK because doesn't realize it just sent out that address as available

It should be relatively easy to replicate this by obtaining a lease, changing hostname, then requesting a new lease.

I'm not the programmer (or even *a* programmer), but the best way to fix this would seem to be to not make the DHCPOFFER of an IP address in the /etc/hosts mappings unless the DHCP client's machine name is the one associated with it.

Let me know if I can do any further testing or provide additional information.

Revision history for this message
Thierry Carrez (ttx) wrote :

Yes, I wouldn't be surprised if your hunch was correct. That's a rather unusual combination of parameters :)

Changed in dnsmasq:
importance: Undecided → Low
status: Incomplete → New
Revision history for this message
Simon Kelley (simon-thekelleys) wrote :

Simon Kelley here: I'm the principal author of dnsmasq.

I have a couple of questions for FactTech:

1) Was the text message in the DHCPNAK log entry the same as the initial reporter's ("address reserved")?
2) Is there any other dhcp-host line in the dnsmasq configuration which might apply to the host in question?

If you can reproduce the bug easily, I'd really like to see the result of turning on "log-dhcp" in dnsmasq.conf

Cheers,

Simon.

Revision history for this message
Simon Kelley (simon-thekelleys) wrote :

I think I've deduced what is happening here. The combination of the dhcp-host line and the /etc/hosts entry generates the equivalent of

dhcp-host=name,192.168.X.X

When you run Ubuntu, the DHCP requests send the name, so dnsmasq find and uses this line, and all is good.

When the machine was rebooted with the install disk, the name is not sent. At DISCOVER time, the 192.168.X.X address gets offered, because that machine (based on MAC address) already has a lease on the that address. At REQUEST time, the address is disallowed, becasue it's been set as a static address for another machine (remember, no name to match the dhcp-host line.)

This hasn't been seen often, because most people nail down static addresses using the MAC address.

Given that, this should be fairly easy to fix: I believe that

http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.48test6.tar.gz

will do the trick.

Cheers,

Simon.

Revision history for this message
Thierry Carrez (ttx) wrote :

Thanks Simon ! I guess we'll wait for the 2.48 release, then :)

Changed in dnsmasq:
status: New → Triaged
Revision history for this message
Simon Kelley (simon-thekelleys) wrote :

2.48 release is now available and includes the fix for this bug.

Cheers,

Simon.

Revision history for this message
Thierry Carrez (ttx) wrote :

Simon:
Good news. Do you plan to push that release to Debian soon ?

Revision history for this message
Simon Kelley (simon-thekelleys) wrote : Re: [Bug 327703] Re: DHCP Request Cycle can get caught in infinite loop

Thierry Carrez wrote:
> Simon:
> Good news. Do you plan to push that release to Debian soon ?
>

It went last night, so should be in unstable very soon, if not already.

Cheers,

Simon.

Revision history for this message
Thierry Carrez (ttx) wrote :

2.48-2 is in Karmic

Changed in dnsmasq (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.