[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DCHP



Cassiel <raffaele.morelli@gmail.com> writes:
>
>    Every time I restart my Lenny I obtain a new ip addr from one of the 2
>    dhcp servers. We have a 1 month lease on this servers and this should
>    never happen within this period.
>    any experience on this?

I'm assuming that your interfaces are automatically configured and
deconfigured by the startup scripts and so implicitly by "ifup" and
"ifdown" using the configuration in "/etc/network/interfaces".  I'm
also further assuming you have the "dhcp3-client" package installed.

The "dhclient3" DHCP client in the "dhcp3-client" package is capable
of reacquiring an old lease on reboot, but the reason it isn't working
is because of an issue with the Debian "ifdown" program.  It's
hardcoded to run "dhclient3 -r ..."  on interface shutdown.  This
causes "dhclient3" to release the lease and change the times in the
"/var/lib/dhcp3/dhclient.xxx.leases" file to expire the lease before
exiting.  If it wasn't for this, "dhclient3" would happily try to
reuse that lease after reboot.

You can work around this by explicitly specifying commands to bring
the interface up and down.  Assuming the interface is "eth0", first
bring it down with "ifdown eth0".  Then, in "/etc/network/interfaces",
find the clause for your interface, which will probably look like
this:

        iface eth0 inet dhcp

and change it to this:

        iface eth0 inet manual
              up dhclient3 -lf /var/lib/dhcp3/dhclient.$IFACE.leases -pf /var/run/dhclient.$IFACE.pid $IFACE
              down kill $(< /var/run/dhclient.$IFACE.pid)

The "up" line here (make sure it's all one line) is the same as the
internal version hardcoded into "ifup".  The "down" line is changed to
simply kill the old "dhclient3" instead of running "dhclient3 -r ..."
as mentioned above.

Now, do "ifup eth0" again.  The first time, it'll allocate a new IP
address.  Make sure "dhclient3" is running.  Now, try "ifdown eth0",
and make sure "dhclient3" is no longer running.  Finally, try "ifup
eth0" again, and you'll hopefully get back your old IP address.
Try rebooting, and---again---you should get back your old IP address.

Good luck.

-- 
Kevin Buhr <buhr+debian@asaurus.net>


Reply to: