Configure DHCP to update DNS records with BIND9

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Configure DHCP to update DNS records with BIND9

Samba - General mailing list
Hallo all,
I configured DHCPD on two of my DCs to update the DNS records according to the wiki (https://w
iki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9).

This works fine except when a lease expires the records are not deleted.

In the log I see this with an added record:

Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[0] = /etc/dhcp/bin/dhcp-dyndns.sh
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[1] = add
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[2] = 192.168.X.X
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[3] = 1:0:00:00:00:00:00
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[4] = NAME


When a lease expires I see this:

Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[0] = /etc/dhcp/bin/dhcp-dyndns.sh
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[1] = delete
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[2] = 192.168.X.X
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[3] =
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[4] = 0
Jul  7 07:46:09 dc1 dhcpd: USAGE:
Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh add ip-address dhcid|mac-address hostname
Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh delete ip-address dhcid|mac-address
Jul  7 07:46:09 dc1 dhcpd: execute: /etc/dhcp/bin/dhcp-dyndns.sh exit status 256

I the wiki the lines for adding a record in "/etc/dhcp/dhcpd.conf" are

execute("/etc/dhcp/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName);

for deletion

execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0");

as you can see the Name should be argv[4] the MAC should be argv[3]. For deletion this isn't
the case and the script checks for MAC (# Exit if no ip address or mac-address) and exits with
usage.

I checked this running this by hand:

runuser -l dhcpd -c "/etc/dhcp/bin/dhcp-dyndns.sh delete 192.168.6.1  0"

works

runuser -l dhcpd -c "/etc/dhcp/bin/dhcp-dyndns.sh delete 192.168.6.1 '' 0"

does not.

As it works for the author I think this might be distribution specific (I am on Centos 7)
thing of interpreting ""?
I have changed my dhcp.conf to include this when a lease expires:

execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP,"0");

This works for us. Should this be added to the WIKI?

hope this helps somebody.

Regards

Christian

--
Dr. Christian Naumer
Research Scientist
Plattform-Koordinator Bioprozesstechnik

B.R.A.I.N Aktiengesellschaft
Darmstaedter Str. 34-36, D-64673 Zwingenberg
e-mail [hidden email], homepage www.brain-biotech.de
fon +49-6251-9331-30  /   fax +49-6251-9331-11

Sitz der Gesellschaft: Zwingenberg/Bergstrasse
Registergericht AG Darmstadt, HRB 24758
Vorstand: Dr. Juergen Eck (Vorsitzender), Frank Goebel
Aufsichtsratsvorsitzender: Dr. Ludger Mueller

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba
Reply | Threaded
Open this post in threaded view
|

Re: Configure DHCP to update DNS records with BIND9

Samba - General mailing list
On Fri, 14 Jul 2017 14:43:30 +0200
Christian Naumer via samba <[hidden email]> wrote:

> Hallo all,
> I configured DHCPD on two of my DCs to update the DNS records
> according to the wiki (https://w
> iki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9).
>
> This works fine except when a lease expires the records are not
> deleted.
>
> In the log I see this with an added record:
>
> Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[0]
> = /etc/dhcp/bin/dhcp-dyndns.sh Jul  7 07:46:12 dc1 dhcpd:
> execute_statement argv[1] = add Jul  7 07:46:12 dc1 dhcpd:
> execute_statement argv[2] = 192.168.X.X Jul  7 07:46:12 dc1 dhcpd:
> execute_statement argv[3] = 1:0:00:00:00:00:00 Jul  7 07:46:12 dc1
> dhcpd: execute_statement argv[4] = NAME
>
>
> When a lease expires I see this:
>
> Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[0]
> = /etc/dhcp/bin/dhcp-dyndns.sh Jul  7 07:46:09 dc1 dhcpd:
> execute_statement argv[1] = delete Jul  7 07:46:09 dc1 dhcpd:
> execute_statement argv[2] = 192.168.X.X Jul  7 07:46:09 dc1 dhcpd:
> execute_statement argv[3] = Jul  7 07:46:09 dc1 dhcpd:
> execute_statement argv[4] = 0 Jul  7 07:46:09 dc1 dhcpd: USAGE:
> Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh add ip-address
> dhcid|mac-address hostname Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh
> delete ip-address dhcid|mac-address Jul  7 07:46:09 dc1 dhcpd:
> execute: /etc/dhcp/bin/dhcp-dyndns.sh exit status 256
>
> I the wiki the lines for adding a record in "/etc/dhcp/dhcpd.conf" are
>
> execute("/etc/dhcp/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID,
> ClientName);
>
> for deletion
>
> execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0");
>
> as you can see the Name should be argv[4] the MAC should be argv[3].
> For deletion this isn't the case and the script checks for MAC (#
> Exit if no ip address or mac-address) and exits with usage.
>
> I checked this running this by hand:
>
> runuser -l dhcpd -c "/etc/dhcp/bin/dhcp-dyndns.sh delete 192.168.6.1
> 0"
>
> works
>
> runuser -l dhcpd -c "/etc/dhcp/bin/dhcp-dyndns.sh delete 192.168.6.1
> '' 0"
>
> does not.
>
> As it works for the author I think this might be distribution
> specific (I am on Centos 7) thing of interpreting ""?
> I have changed my dhcp.conf to include this when a lease expires:
>
> execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP,"0");
>
> This works for us. Should this be added to the WIKI?
>
> hope this helps somebody.
>
> Regards
>
> Christian
>

Before getting that far, can you post the entire block from the log,
from where the computer either asks to renew (or in your case expire)
the lease to were the message 'DHCP-DNS Update' is printed and then I
can try and understand what is going on.

Rowland

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba
Reply | Threaded
Open this post in threaded view
|

Re: Configure DHCP to update DNS records with BIND9

Samba - General mailing list

Am Freitag, den 14.07.2017, 14:35 +0100 schrieb Rowland Penny via samba:
>
> Before getting that far, can you post the entire block from the log,
> from where the computer either asks to renew (or in your case expire)
> the lease to were the message 'DHCP-DNS Update' is printed and then I
> can try and understand what is going on.

In this case the dhcp-server says the lease expired. The release of the IP by the computer
works (the MAC is argv[3] in the release part in the wiki). See the three cases below:

here the entries for the "add"

Jul  7 07:46:11 dc1 dhcpd: DHCPDISCOVER from 00:00:00:00:00:00 via eth0
Jul  7 07:46:12 dc1 dhcpd: DHCPOFFER on 192.168.4.4 to 00:00:00:00:00:00 (NAME) via eth0
Jul  7 07:46:12 dc1 dhcpd: Commit: IP: 192.168.4.4 DHCID: 1:0:e0:c5:39:18:ef Name: NAME
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[0] = /etc/dhcp/bin/dhcp-dyndns.sh
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[1] = add
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[2] = 192.168.4.4
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[3] = 1:00:00:00:00:00:00
Jul  7 07:46:12 dc1 dhcpd: execute_statement argv[4] = NAME
Jul  7 07:46:13 dc1 named[818]: samba_dlz: starting transaction on zone hq.samdom.de
Jul  7 07:46:13 dc1 named[818]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=NAME.hq.samdom.de tcpaddr=127.0.0.1 type=A key=3493294157.sig-dc1.hq.samdom.de/160/0
Jul  7 07:46:13 dc1 named[818]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=NAME.hq.samdom.de tcpaddr=127.0.0.1 type=A key=3493294157.sig-dc1.hq.samdom.de/160/0
Jul  7 07:46:13 dc1 named[818]: client 127.0.0.1#39439/key dhcpduser\@HQ.samdom.de: updating
zone 'hq.samdom.de/NONE': deleting rrset at 'NAME.hq.samdom.de' A
Jul  7 07:46:13 dc1 named[818]: samba_dlz: subtracted rdataset NAME.hq.samdom.de
'NAME.hq.samdom.de.#0113600#011IN#011A#011192.168.4.4'
Jul  7 07:46:13 dc1 named[818]: client 127.0.0.1#39439/key dhcpduser\@HQ.samdom.de: updating
zone 'hq.samdom.de/NONE': adding an RR at 'NAME.hq.samdom.de' A
Jul  7 07:46:13 dc1 named[818]: samba_dlz: added rdataset NAME.hq.samdom.de
'NAME.hq.samdom.de.#0113600#011IN#011A#011192.168.4.4'
Jul  7 07:46:13 dc1 named[818]: samba_dlz: committed transaction on zone hq.samdom.de
Jul  7 07:46:13 dc1 named[818]: samba_dlz: starting transaction on zone 4.168.192.in-addr.arpa
Jul  7 07:46:13 dc1 named[818]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=4.4.168.192.in-addr.arpa tcpaddr=127.0.0.1 type=PTR key=3852624973.sig-
dc1.hq.samdom.de/160/0
Jul  7 07:46:13 dc1 named[818]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=4.4.168.192.in-addr.arpa tcpaddr=127.0.0.1 type=PTR key=3852624973.sig-
dc1.hq.samdom.de/160/0
Jul  7 07:46:13 dc1 named[818]: client 127.0.0.1#38461/key dhcpduser\@HQ.samdom.de: updating
zone '4.168.192.in-addr.arpa/NONE': deleting rrset at '4.4.168.192.in-addr.arpa' PTR
Jul  7 07:46:13 dc1 named[818]: samba_dlz: subtracted rdataset 4.4.168.192.in-addr.arpa
'4.4.168.192.in-addr.arpa.#0113600#011IN#011PTR#011NAME.hq.samdom.de.'
Jul  7 07:46:13 dc1 named[818]: client 127.0.0.1#38461/key dhcpduser\@HQ.samdom.de: updating
zone '4.168.192.in-addr.arpa/NONE': adding an RR at '4.4.168.192.in-addr.arpa' PTR
Jul  7 07:46:13 dc1 named[818]: samba_dlz: added rdataset 4.4.168.192.in-addr.arpa
'4.4.168.192.in-addr.arpa.#0113600#011IN#011PTR#011NAME.hq.samdom.de.'
Jul  7 07:46:13 dc1 named[818]: samba_dlz: committed transaction on zone 4.168.192.in-
addr.arpa
Jul  7 07:46:13 dc1 logger: DHCP-DNS Update succeeded
Jul  7 07:46:13 dc1 dhcpd: DHCPREQUEST for 192.168.4.4 (192.168.0.90) from 00:00:00:00:00:00
(NAME) via eth0
Jul  7 07:46:13 dc1 dhcpd: DHCPACK on 192.168.4.4 to 00:00:00:00:00:00 (NAME) via eth0


Here the entries for the "delete", This is all nothing more.

Jul  7 07:46:09 dc1 dhcpd: Expired: IP: 192.168.2.3
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[0] = /etc/dhcp/bin/dhcp-dyndns.sh
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[1] = delete
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[2] = 192.168.2.3
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[3] =
Jul  7 07:46:09 dc1 dhcpd: execute_statement argv[4] = 0
Jul  7 07:46:09 dc1 dhcpd: USAGE:
Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh add ip-address dhcid|mac-address hostname
Jul  7 07:46:09 dc1 dhcpd: dhcp-dyndns.sh delete ip-address dhcid|mac-address
Jul  7 07:46:09 dc1 dhcpd: execute: /etc/dhcp/bin/dhcp-dyndns.sh exit status 256



And for completion the "release"


Jul 14 16:09:59 dc1 dhcpd: Release: IP: 192.168.0.154
Jul 14 16:09:59 dc1 dhcpd: execute_statement argv[0] = /etc/dhcp/bin/dhcp-dyndns.sh
Jul 14 16:09:59 dc1 dhcpd: execute_statement argv[1] = delete
Jul 14 16:09:59 dc1 dhcpd: execute_statement argv[2] = 192.168.0.154
Jul 14 16:09:59 dc1 dhcpd: execute_statement argv[3] = 1:00:00:00:00:00:00
Jul 14 16:09:59 dc1 dhcpd: execute_statement argv[4] = Win10
Jul 14 16:09:59 dc1 named[736]: samba_dlz: starting transaction on zone hq.samdom.de
Jul 14 16:09:59 dc1 named[736]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=Win10.hq.samdom.de tcpaddr=127.0.0.1 type=A key=632327721.sig-dc1.hq.samdom.de/160/0
Jul 14 16:09:59 dc1 named[736]: client 127.0.0.1#41375/key dhcpduser\@HQ.samdom.de: updating
zone 'hq.samdom.de/NONE': deleting rrset at 'Win10.hq.samdom.de' A
Jul 14 16:09:59 dc1 named[736]: samba_dlz: subtracted rdataset Win10.hq.samdom.de
'Win10.hq.samdom.de.#0113600#011IN#011A#011192.168.0.154'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: subtracted rdataset hq.samdom.de
'hq.samdom.de.#0113600#011IN#011SOA#011dc1.hq.samdom.de. hostmaster.hq.samdom.de. 14877 900
600 86400 3600'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: added rdataset hq.samdom.de
'hq.samdom.de.#0113600#011IN#011SOA#011dc1.hq.samdom.de. hostmaster.hq.samdom.de. 14878 900
600 86400 3600'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: committed transaction on zone hq.samdom.de
Jul 14 16:09:59 dc1 named[736]: samba_dlz: starting transaction on zone 0.168.192.in-addr.arpa
Jul 14 16:09:59 dc1 named[736]: samba_dlz: allowing update of signer=dhcpduser\@HQ.samdom.de
name=154.0.168.192.in-addr.arpa tcpaddr=127.0.0.1 type=PTR key=777394679.sig-
dc1.hq.samdom.de/160/0
Jul 14 16:09:59 dc1 named[736]: client 127.0.0.1#59236/key dhcpduser\@HQ.samdom.de: updating
zone '0.168.192.in-addr.arpa/NONE': deleting rrset at '154.0.168.192.in-addr.arpa' PTR
Jul 14 16:09:59 dc1 named[736]: samba_dlz: subtracted rdataset 154.0.168.192.in-addr.arpa
'154.0.168.192.in-addr.arpa.#0113600#011IN#011PTR#011Win10.hq.samdom.de.'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: subtracted rdataset 0.168.192.in-addr.arpa
'0.168.192.in-addr.arpa.#0113600#011IN#011SOA#011dc1.hq.samdom.de. hostmaster.hq.samdom.de.
1372 900 600 86400 3600'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: added rdataset 0.168.192.in-addr.arpa
'0.168.192.in-addr.arpa.#0113600#011IN#011SOA#011dc1.hq.samdom.de. hostmaster.hq.samdom.de.
1373 900 600 86400 3600'
Jul 14 16:09:59 dc1 named[736]: samba_dlz: committed transaction on zone 0.168.192.in-
addr.arpa
Jul 14 16:09:59 dc1 logger: DHCP-DNS Update succeeded
Jul 14 16:09:59 dc1 dhcpd: DHCPRELEASE of 192.168.0.154 from 00:00:00:00:00:00 (Win10) via
eth0 (found)


Regards

Christian



>
> Rowland
>

--
Dr. Christian Naumer
Research Scientist
Plattform-Koordinator Bioprozesstechnik

B.R.A.I.N Aktiengesellschaft
Darmstaedter Str. 34-36, D-64673 Zwingenberg
e-mail [hidden email], homepage www.brain-biotech.de
fon +49-6251-9331-30  /   fax +49-6251-9331-11

Sitz der Gesellschaft: Zwingenberg/Bergstrasse
Registergericht AG Darmstadt, HRB 24758
Vorstand: Dr. Juergen Eck (Vorsitzender), Frank Goebel
Aufsichtsratsvorsitzender: Dr. Ludger Mueller

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba
Reply | Threaded
Open this post in threaded view
|

Re: Configure DHCP to update DNS records with BIND9

Samba - General mailing list

OK, can you try the attached script, this will replace the
dhcp-dyndns.sh script you have now, you will also need to ensure it is
executable.

You will also need to alter your dhcpd.conf file, find this:

on expiry {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
# cannot get a ClientMac here, apparently this only works when actually receiving a packet
log(concat("Expired: IP: ", ClientIP));
# cannot get a ClientName here, for some reason that always fails
execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0");
}

Change the last line to this:

execute("/etc/dhcp/bin/dhcp-dyndns.sh", "delete", ClientIP);

Restart dhcpd and you should now find it works (famous last words :-) )

Rowland
--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba
Reply | Threaded
Open this post in threaded view
|

Re: Configure DHCP to update DNS records with BIND9

Samba - General mailing list
Thanks Rowland. I already got it working with a "workaround". Your fix is definitively more
elegant. However, doesn't work on all setups. See below.

Am Samstag, den 15.07.2017, 12:49 +0100 schrieb Rowland Penny via samba:
> OK, can you try the attached script, this will replace the
> dhcp-dyndns.sh script you have now, you will also need to ensure it is
> executable.
>

This would not work as I don't have "dhcp-lease-list". This is apparently only included from
4.3 and centos 7 ships with 4.2.x.

So I'll leave my "fix" as is at the moment.


Regards


Christian

--
Dr. Christian Naumer
Research Scientist
Plattform-Koordinator Bioprozesstechnik

B.R.A.I.N Aktiengesellschaft
Darmstaedter Str. 34-36, D-64673 Zwingenberg
e-mail [hidden email], homepage www.brain-biotech.de
fon +49-6251-9331-30  /   fax +49-6251-9331-11

Sitz der Gesellschaft: Zwingenberg/Bergstrasse
Registergericht AG Darmstadt, HRB 24758
Vorstand: Dr. Juergen Eck (Vorsitzender), Frank Goebel
Aufsichtsratsvorsitzender: Dr. Ludger Mueller

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba