dhcp3 server "forgets" leases (new lease at each reboot)

Bug #24292 reported by Gerald Bastelica on 2005-10-19
4
Affects Status Importance Assigned to Milestone
ifupdown (Ubuntu)
Medium
Scott James Remnant (Canonical)

Bug Description

dhcpd3 v3.0.2

Simple classic range (range, dns, router).

1 client (tested with kubuntu 5.04 PowerPC & pxe based linux client) booting and
configured with DHCP.

At each reboot, the dhcp server gives a NEW address, not the one previously
used. Of course leases time sufficiently long.

I tried to download and compile v3.0.3 from isc.org website, using the default
compilation and the same configuration dhcpd.conf file: It's OK, the SAME
address is given at each reboot. But i have to figure out how to compile to be
"ubuntu-compatible" (executable is dhcpd3 not dhcpd, configuration file is
/etc/dhcp3/dhcpd.conf not /etc/dhcpd.conf, ...).

Seems to be a bug in v3.0.2

Gerald Bastelica (gb-pub1) wrote :

This bug has been found with ubuntu-server 5.10.

Matt Zimmerman (mdz) wrote :

Not reproducible here; dynamically-assigned addresses are persistent across
reboots. Please provide more information about your diagnostic efforts

Could be related to the fact that dhclient can't write its leases anymore? :)
pitti attacked it with the derooting gun, and since then it's trying to write
(as dhcp) to /var/run (which is only writable as root) or overwrite existing
lease files which are owned by root.

Martin Pitt (pitti) wrote :

At least my dhclient writes its lease into /var/lib/dhcp3, which is owned by
user 'dhcp'. Can you please give me the output of

  ls -ld /var/lib/dhcp3
  ls -l /var/lib/dhcp3
  ls -l /var/run/dhclient*

Thanks!

It might be entirely possible that this got screwed in the latest dapper merge,
though.

Martin Pitt (pitti) wrote :

(In reply to comment #3)
> Could be related to the fact that dhclient can't write its leases anymore? :)
> pitti attacked it with the derooting gun, and since then it's trying to write
> (as dhcp) to /var/run (which is only writable as root) or overwrite existing
> lease files which are owned by root.

At the time the leases file is written, the dhcp3 client still has root
privileges, and indeed it writes his leases files as the root user (please send
me the ls -l output to confirm for you; it works for me here). There is a bug,
in the current version the file is closed and reopened, which fails as non-root.
I will fix that, but that is pretty much a corner case.

I think your problem is: when calling 'sudo dhclient eth0', the default lease
file is written into /var/lib/dhcp3. However, when the Debian/Ubuntu way of
configuring network interfaces is used (sudo ifup eth0, same on boot), ifupdown
overwrites this path to /var/run. But /var/run is cleaned at every boot, so the
leases file does not survive.

So ifupdown needs to be fixed to not overwrite the lease file path.

Martin Pitt (pitti) wrote :

DHCP corner case fixed:

 dhcp3 (3.0.3-5ubuntu3) dapper; urgency=low
 .
   * debian/patches/deroot-client.dpatch:
     - rewrite_client_leases(): Truncate and rewind the leases file instead of
       closing and reopening it. The latter is not possible any more with
       dropped root privileges.
     - See bug #24292 (which has a different cause, but led to discovering this
       one).

Fixing the path in ifupdown is easy, however, it might break other programs that
rely on the current path, so this needs some more consideration.

And ifupdown fixed to write the leases file to /var/lib/dhcp3 (it overrides it
because it includes the interface name in the filename which dhclient doesn't)

Gerald Bastelica (gb-pub1) wrote :

Created an attachment (id=5085)
/var/log/messages : dhcpd logs

Gerald Bastelica (gb-pub1) wrote :

Created an attachment (id=5086)
Complete dhcpd.leases file

Gerald Bastelica (gb-pub1) wrote :

Hi,

I've tried again, and i still having the same results !

My test configuration is:

- Server: Xeon based, installed with ubuntu 5.10 (full version) CD using
"server" option at installation CD's prompt. Installation made with french
language. Then apt-get update, apt-get install linux-image-686-smp, apt-get
upgrade, apt-get install dhcp3-server.

- Client: Pentium M based laptop, installed with Ubuntu 5.04.

These are configurations used for the server:

/etc/network/interfaces:
auto lo
iface lo inet loopback
mapping hotplug
        script grep
        map eth0
iface eth0 inet static
     address 192.168.1.1
     netmask 255.255.255.0

dhcpd.conf:
ddns-update-style none;

default-lease-time 600;
max-lease-time 7200;

authoritative;

log-facility local7;

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option domain-name-servers 62.23.95.97;
  option domain-name "internal.example.org";
  option routers 192.168.1.1;
  default-lease-time 600;
  max-lease-time 7200;
}

Both server and client are connected to a stand-alone switch, with no other
computer.

- First laptop boot using Ubuntu. Got 192.168.1.200.
- ifdown/ifup eth0 : still getting 192.168.1.200
- ifdown/ifup again : 192.168.1.200 again
- reboot to Ubuntu : Got 192.168.1.199 !!!
- reboot to Ubuntu : Got 192.168.1.198 !!!
- reboot to Windows XP : Got 192.168.1.197 !!!

So these results confirm my previous test, so i still having a very nasty bug
here. I didn't had it with Ubuntu 5.04, or downloading and compiling 3.0.3 dhcp
server.

It's strange that you can't reproduce it, because i've test it 3 times,
installing a fresh new server each time.

I can made some other tests if you have some ideas.

Best regards,

Gerald Bastelica (gb-pub1) wrote :

Additional question:

Martin Pitt talks about dhcp3 (3.0.3-5ubuntu3). With Ubuntu 5.10 and standard
repositories, there's no upgrade from 3.0.2 to 3.0.3 available. Am i missing
something ? Is this available on another repository ?

Thanks for your help.

(In reply to comment #11)

> Martin Pitt talks about dhcp3 (3.0.3-5ubuntu3). With Ubuntu 5.10 and standard
> repositories, there's no upgrade from 3.0.2 to 3.0.3 available. Am i missing
> something ? Is this available on another repository ?
>
It's fixed in dapper (future Ubuntu 6.04), we don't retroactively apply bug
fixes to released versions of Ubuntu.

Re-marking as fixed, as this has been fixed in dapper -- I've just tested it
here again and it works for me.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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