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

Re: Does DNSMasq (or other DNS/DHCP Servers) Cache Old Addresses?

On Tue, Mar 3, 2009 at 8:56 AM, Hal Vaughan <hal@halblog.com> wrote:
> I'm adding a new system to my LAN.  The DNS is running DNSMasq and is on
> Etch.  The new system is running Lenny.  I edited the
> /etc/network/interfaces file to include the following (other than loopback,
> the only interface in the file):
> auto eth0
> iface eth0 inet static
> address
> netmask
> gateway
> Originally, when Debian set up the system, it used DHCP instead of a static
> IP.  This IP address ( is defined on the DNS server in
> /etc/hosts (which DNSMasq uses for config).  When Debian-Lenny set this up
> under DHCP, it was assigned the address  I edited the
> interfaces file to include the above.  If I did "/etc/init.d/networking
> restart," then it would again get the ...131 address.  If I did "ifup eth0"
> (after doing ifdown first), then it'd get the 111 address it should have,
> but in at least one case, a few minutes later I checked and it was back to
> 131.
> I finally shut down the new system and rebooted the DNS server -- after
> having shut off networking on the new system and restarting DNSMasq on the
> DNS.  Then I brought up the DNS server, and after that, brought up the new
> system.  Now it's working and it finally let me define eth0:0 as well (which
> it kept choking on before).
> So why did it keep getting forced to use the address instead of
> the one ending in 111?  Did DNSMasq cache the MAC address or did the new
> workstation cache the info and reuse it automatically?  What was it that the
> reboot would have restarted that would allow this system to finally get the
> specified address after the reboot?
There's no problem with the server - and techincally no *configuration*
problem with the client. It is the norm for a DHCP server to give the same
address every time to a given machine unless there is a particular reason
not to, so if the client makes a DHCP request then it will get its
preferred dynamic IP (off the top of my head I don't recall whether this
is because the client requests it or because the server stores the MAC
address, but it's definitely the usual behaviour). The question then is
why the client was asking for a dynamic IP address when it had a static
address configured, and the answer is probably as follows:

You changed /etc/network/interfaces, and then did /etc/init.d/networking
restart, yes? In this case, you had a DHCP client running, then switched
to static configuration. Restarting networking causes the interfaces
defined to be brought down, but because you had changed it, there were no
DHCP interfaces defined, so dhclient was never stopped. The static
interface was then brought up correctly, but the dhclient still running
would periodically make a DHCP request and overwrite it. Killing dhclient
would have solved your problem, or obviously rebooting, as you found.


Reply to: