gclayburg / synology-diskstation-scripts

Update Synology DNS records from DHCP IP address reservation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synology DCHP / DNS update script broken in DSM 6.0-7321

chriscjcj opened this issue · comments

The script that takes the Synology DHCP database and creates DNS A records from them is unfortunately broken in DSM 6. The script runs and deletes all A records from the DNS zone file, but it no longer repopulates it. So, if you update to DSM 6, beware... you'll have an empty zone file. I attempted to reach out to Tim Smith through the Synology forums, but his last post was in 2014 and he hasn't responded yet. I have been trying to figure this one out myself, but I'm in over my head. Any chance you could take a look at it and see if you can figure out why it's not working?

The original thread where this script was discussed can be found here:
https://forum.synology.com/enu/viewtopic.php?f=233&t=88517&p=429340

Many thanks,
-Chris Johnson

Hi Chris, I have had the same issue, and I have found a solution.
If you run the script in DSM v6 on the console then the following erorr is shown:

awk: cmd. line:5: fatal: cannot open file `/etc/dhcpd/dhcpd-static-static.conf' for reading (No such file or directory)

The name of the DHCPStatic file containing the reservations has changed:
/etc/dhcpd/dhcpd-eth0-static.conf

So change the line contains the "DHCPStatic" in your script:
from: DHCPStatic=/etc/dhcpd/dhcpd-static-static.conf
to: DHCPStatic=/etc/dhcpd/dhcpd-eth0-static.conf

On my DSM v6 this script workes again as before! :-)

Regards, Rene

Good catch, guys. I haven't yet tried this on DSM 6, but I plan to shortly. I'll update these scripts so that they work on both DSM 5 and 6. Testing might be a bit tricky though, since I only have one synology server to work with.

Rene, Thank you so very much for posting this! It works for me as well. I shall post this fix in the Synology forum where this script was originally discussed.

Or better yet, @zimmerlis , could you create a pull request from with your script update?

I'll update these scripts so that they work on both DSM 5 and 6. Testing might be a bit tricky though, since I only have one synology server to work with.

I will be happy to test it on DSM 6. Just let me know. 👍

@chriscjcj @zimmerlis I wonder if you guys are using an older version of this script. I added error checking quite some time ago to first check for the existence of the DHCP static leases file.

BTW, I just also updated the script to also check for leases that may exist in the /etc/dhcpd/dhcpd-eth0-static.conf file. @chriscjcj can you verify that this script now works under DSM 6?

I was indeed using a rather old version of this script. I have updated with the most current revision. (3317c4e) I deleted several A records from the zone file which were based on DHCP lease reservations. I then ran the script. The script successfully repopulated the zone file with all of the host names from the DHCP server. So near as I can tell, it works beautifully.

THANK YOU for your assistance on this. I'm truly grateful. If you ever find yourself in San Francisco, please let me know. I'll buy you a beer. :-)

P.S. Just installed DSM 6.0-7321 Update 2. Script works fine under both the initial DSM6 release as well as this "update 2."

First off thanks for this! It is working great for me. One note on above in DSM 6.0 it appears that it went from a single static file to one per interface that DHCP is configured on. For example: I have DHCP only on the 4th Ethernet adapter (eth3) and so I don't have a -static-static or a -eth0-static and instead only have a -eth3-static. So it looks like the fix for 6.0 would be to add in static entries from any file -ethX-static.

I have a potential pull request for this but I think there would have to be a decision of do we have this concatenate together all ethX or make it a setting to pick which one (defaulting to eth0)?

I could imagine a world where someone wants different reverse zones updated from different ethX files if there are different IP ranges on multiple NICs... but maybe that isn't an issue...

On my system, I notice static dhcp-host addresses appear in both /etc/dhcpd/dhcpd-static-static.conf and /etc/dhcpd/dhcpd.conf. Both of these files are scanned by the script as it is now. @tonysurma does your system have duplicate dhcp-host entries?

My system uses the name "bond0" as the interface name. Maybe the simplest thing to do here is just look for dhcp-host entries in any /etc/dhcpd/dhcpd*static.conf file.

on mine DS1515 on 6.1 I have nothing in dhcpd.conf and just in the static.conf file(s) (in my case only eth3 as I only have it live on my 4th NIC.

That all being said I just ran the current versions from your repo and all works properly so looks like it is fixed (for me at least)

Apologies for delay in testing but I think this can be closed - thanks again @gclayburg

For you folks running DSM 6, you might check the latest version just committed. @WolfspiritM created a PR that does a better job of determining network interfaces on your system.