Discussion:
[Dnsmasq-discuss] prevent dnsmasq from releasing IPs
Stefan Priebe - Profihost AG
2016-01-25 16:42:14 UTC
Permalink
Hi,

is there any way to keep IPs in the dnsmasq DB even the host sends a
release?

I want to keep those entry at least for 2 more days.

Greets,
Stefan
Simon Kelley
2016-01-25 22:20:03 UTC
Permalink
Not directly. If you just want a record of leases after they've been
released, then you can save information by using the dhcp-script
function. If you want to stop re-use of the addresses, then the best
you can easily do is to allocate static addresses to clients. That
will stop the addresses being allocated to other clients, even
when not leased.


Cheers,

Simon.
Post by Stefan Priebe - Profihost AG
Hi,
is there any way to keep IPs in the dnsmasq DB even the host sends
a release?
I want to keep those entry at least for 2 more days.
Greets, Stefan
_______________________________________________ Dnsmasq-discuss
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Stefan Priebe - Profihost AG
2016-01-26 07:25:55 UTC
Permalink
Post by Simon Kelley
Not directly. If you just want a record of leases after they've been
released, then you can save information by using the dhcp-script
function. If you want to stop re-use of the addresses, then the best
you can easily do is to allocate static addresses to clients. That
will stop the addresses being allocated to other clients, even
when not leased.
I had the hope that dnsmasq evaluate the return code of the dhcp-script
and i can use exit 1 if i do not want to delete the IP.

Is it possible that i readd the IP to the leases file in the
dhcp-script? Or does dnsmasq remove the entry after processing the
dhcp-script?

Stefan
Post by Simon Kelley
Cheers,
Simon.
Post by Stefan Priebe - Profihost AG
Hi,
is there any way to keep IPs in the dnsmasq DB even the host sends
a release?
I want to keep those entry at least for 2 more days.
Greets, Stefan
_______________________________________________ Dnsmasq-discuss
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Simon Kelley
2016-01-26 13:32:44 UTC
Permalink
Post by Stefan Priebe - Profihost AG
Post by Simon Kelley
Not directly. If you just want a record of leases after they've
been released, then you can save information by using the
dhcp-script function. If you want to stop re-use of the
addresses, then the best you can easily do is to allocate static
addresses to clients. That will stop the addresses being
allocated to other clients, even when not leased.
I had the hope that dnsmasq evaluate the return code of the
dhcp-script and i can use exit 1 if i do not want to delete the
IP.
That's an interesting thought. The dhcp-script gets run
asynchronously, so it wouldn't be trivial to implement, but it may be
possible.
Post by Stefan Priebe - Profihost AG
Is it possible that i readd the IP to the leases file in the
dhcp-script? Or does dnsmasq remove the entry after processing the
dhcp-script?
That wouldn't work at all. Dnsmasq only reads the contents of the
lease file at startup. The rest of the time it's working from an
internal copy. If you altered the file, your changes would just be
overwritten and ignored.


Cheers,

Simon.
Post by Stefan Priebe - Profihost AG
Stefan
Post by Simon Kelley
Cheers,
Simon.
Post by Stefan Priebe - Profihost AG
Hi,
is there any way to keep IPs in the dnsmasq DB even the host
sends a release?
I want to keep those entry at least for 2 more days.
Greets, Stefan
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
_______________________________________________
Post by Stefan Priebe - Profihost AG
Post by Simon Kelley
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Simon Kelley
2016-01-26 13:46:09 UTC
Permalink
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to

1) Stop dnsmasq with SIGTERM
2) modify the leases file
3) restart dnsmasq


in that order.


Cheers,

Simon.
Stefan Priebe - Profihost AG
2016-01-26 14:56:21 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM
2) modify the leases file
3) restart dnsmasq
in that
Last idea isn't it possible to make the host static on add? If it is which file should I use to add the mac hostname IP combination
Cheers,
Simon.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAEBCAAGBQJWp3ihAAoJEBXN2mrhkTWi9SwP/3bh7wI9Jsa+YMa/PRIQUnDW
WEiMCqNXme1c6KPZ0sFUfaqgcNjbEmQ7ahRW+H22Yr6MXyZmEcK96Geia6Fn0hL+
3kvwjjrJa3oO/mp29AFR8WTOAdQoJdRFycPexDmlWQC7VRV2s/qV1pGOZvS20TZ6
/j1qYjZLm1yMFAVH1ArjC3SOItEt3yT7KaKcvZMC3HXuVyuHDDTIABWYB7DMWV2Z
I/MFWN8kCwQycG3RP3o9f6LEFMkRsvUcR9LDLEnGjErl9rVFh337v7p7afxMHauu
zXn1JpTeh1pl/fsstmzNgIpe61DD/rhxZVvrwlyzSOog/xQnTHxxiXl7Gl4LHkUY
Z1W1qjzCzN3E3sC+cgx/NIB5dOzctSSTzfPLKLisshwYAxaBgOowIRQCQtv6Oovh
Md0oqN2jYYMPAuk+D6hOA0Yuoz2lHANnQMC97gY/6tWDPMSmeAyS4fuN61YJuX41
suydUc+CWwwVmmLkIf0qBY5dk/cgMIepiis3NZutnnOBYyxf9xpvxtLgkTFYyryD
7w+OdOg54ug2jABjinGAhjvcI36y1HilsANbMpED26PiNlKiC4pj99pPUYqzM6GE
Eb0+CA2Ah+c7CGEK1YMnKx78qqCb+tzkD1VfgQSusQaNvsPi+nsb19qfuO8ZDJc6
jXCO2S8dIIS1us8YH4sj
=vL+b
-----END PGP SIGNATURE-----
Neil Jerram
2016-01-26 16:03:47 UTC
Permalink
Post by Stefan Priebe - Profihost AG
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM
2) modify the leases file
3) restart dnsmasq
in that
Last idea isn't it possible to make the host static on add? If it is which file should I use to add the mac hostname IP combination
FYI, at https://github.com/projectcalico/calico/issues/233 we have a
long trail about what we think is the opposite problem. Namely, that
Dnsmasq will not reallocate an IP that should have been released, and
whose old IP/MAC mapping has been removed from the 'host' config file.
As you'll see if you read that trail, we thought this was caused by a
problem in the delivery of the DHCP_RELEASE message to Dnsmasq, and
hence Dnsmasq retaining a record of the old lease in its internal data.

Based on that, I'd expect that if you deliberately did something to stop
the DHCP_RELEASE message from reaching Dnsmasq, Dnsmasq would then
retain the old lease (which I believe is what you're asking for).

However, that understanding does seem to be contradicted by what Simon
has said in this thread, and I would strongly assume that Simon is right
- but perhaps there might still be some hint or useful information in
that issue trail.

Regards,
Neil
Simon Kelley
2016-01-26 21:37:58 UTC
Permalink
Post by Neil Jerram
Post by Stefan Priebe - Profihost AG
Am 26.01.2016 um 14:46 schrieb Simon Kelley
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 26/01/16 13:42, Stefan Priebe - Profihost AG wrote: what
about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM 2) modify the leases file 3)
restart dnsmasq
in that
Last idea isn't it possible to make the host static on add? If it
is which file should I use to add the mac hostname IP
combination
FYI, at https://github.com/projectcalico/calico/issues/233 we have
a long trail about what we think is the opposite problem. Namely,
that Dnsmasq will not reallocate an IP that should have been
released, and whose old IP/MAC mapping has been removed from the
'host' config file. As you'll see if you read that trail, we
thought this was caused by a problem in the delivery of the
DHCP_RELEASE message to Dnsmasq, and hence Dnsmasq retaining a
record of the old lease in its internal data.
Based on that, I'd expect that if you deliberately did something to
stop the DHCP_RELEASE message from reaching Dnsmasq, Dnsmasq would
then retain the old lease (which I believe is what you're asking
for).
That's certainly true.
Post by Neil Jerram
However, that understanding does seem to be contradicted by what
Simon has said in this thread, and I would strongly assume that
Simon is right - but perhaps there might still be some hint or
useful information in that issue trail.
I looks like the problem there is exactly as you say: dnsmasq is
failing to allocate an address because it has run out of free
addresses because addresses have been consumed by machine which are
now "dead" but did not release their address when they died, so the
address is unavailable until the lease period expires.


Cheers,

Simon.
Post by Neil Jerram
Regards, Neil
Simon Kelley
2016-01-26 21:31:29 UTC
Permalink
Post by Simon Kelley
Am 26.01.2016 um 14:46 schrieb Simon Kelley
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM 2) modify the leases file 3) restart
dnsmasq
in that
Last idea isn't it possible to make the host static on add? If it
is which file should I use to add the mac hostname IP
combination
Add the hostname and IP in /etc/hosts, and add the MAC/hostname or
MAC/IP as --dhcp-host configuration.

You can provide all three in --dhcp-host, that will ensure that only
the specified MAC address gets that IP address BUT, the IP/name will
only exist in the DNS whilst the DHCP lease exists. If you want the
hostname to always resolve, you have to put it in /etc/hosts or friend.


Cheers,

Simon.
Post by Simon Kelley
Cheers,
Simon.
Hartmut Krafft
2016-01-27 15:05:32 UTC
Permalink
On Tue, 26 Jan 2016 21:31:29 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Post by Simon Kelley
Am 26.01.2016 um 14:46 schrieb Simon Kelley
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM 2) modify the leases file 3) restart
dnsmasq
in that
Last idea isn't it possible to make the host static on add? If it
is which file should I use to add the mac hostname IP
combination
Add the hostname and IP in /etc/hosts, and add the MAC/hostname or
MAC/IP as --dhcp-host configuration.
You can provide all three in --dhcp-host, that will ensure that only
the specified MAC address gets that IP address BUT, the IP/name will
only exist in the DNS whilst the DHCP lease exists. If you want the
hostname to always resolve, you have to put it in /etc/hosts or friend.
If you want to avoid shutting down dnsmasq you could use the
dhcp-hostsfile and addn-hosts directives (see manpage). You can
regenerate those files while dnsmasq is running and send a hangup
signal to the dnsmasq process which will cause them to be read and the
information updated.
I've made me a unified dhcp+hostsfile input file and a script to
generate both dhcp-hostsfile and addnhost from that because I found
that I preferred not to have to enter redundant data in two files (and
invariably ending up with contradictory entries).
You'll just have to devise a way to enter your information into those
files for your usecase.

Hartmut
Cheers,
Simon.
Nicolas Cavallari
2016-03-01 09:29:14 UTC
Permalink
Post by Simon Kelley
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM
2) modify the leases file
3) restart dnsmasq
in that order.
You forgot about my patches that adds a D-Bus method to add leases to
the internal copy, that you merged in June last year :)

It's documented in dbus/DBus-interface, as you requested :)
Simon Kelley
2016-03-01 15:37:30 UTC
Permalink
Post by Nicolas Cavallari
Post by Simon Kelley
what about writing and sending kill 1 / HUP?
No. The only only way to make that work would be to
1) Stop dnsmasq with SIGTERM 2) modify the leases file 3)
restart dnsmasq
in that order.
You forgot about my patches that adds a D-Bus method to add leases
to the internal copy, that you merged in June last year :)
It's documented in dbus/DBus-interface, as you requested :)
Indeed. What Nicolas said.


Actually, it's worse: sometimes I find code implementing features in
dnsmasq which I wrote, and I have no memory of.......


Cheers,

Simon.

Loading...