[Samba] Conflict entries in DNS with DHCP and dynamic DNS updates 

Samba Fan sambafan at outlook.de
Tue Feb 23 13:00:05 UTC 2021


Hi Christian,

could you share a code sniplet? I run the following code every once in a
while to purge those entries:

IFS= ldbsearch --cross-ncs -H /var/lib/samba/private/sam.ldb -b
'CN=MicrosoftDNS,DC=DomainDnsZones,DC=iqo,DC=uni-hannover,DC=de'
'(DC=*CNF:*)' dn | sed -e 's/\\/\\\\/g' | grep ^dn | while read dn ; do
   ldbdel -H /var/lib/samba/private/sam.ldb "${dn#dn: }"
done

Not sure whether this is the right thing though... Thanks,

Here are my 2 snippets. Both are placed in the Case-Action-Delete part of Rowland's script. Snippet 1 right after deleting the "working" A record, snippet 1 right after deleting the "working" PTR record.

# snippet 1
CNF_UID=$(samba-tool dns query ${Server} ${domain} @ ALL -k yes 2>/dev/null | grep -i -A 1 "${name}" | grep -i -m 1 "CNF:" | awk -F "," '{print $1}')
if [ -z "${CNF_UID}" ]; then
logger "No CNF entry found (=> no conflict). That's fine."
else
logger "CNF Record found. There was a conflict and should be cleaned up now."
logger "Record to delete from DNS: ${name}${CNF_UID}"
samba-tool dns delete ${Server} ${domain} "${name}"$'\n'"${CNF_UID}" A ${ip} -k yes
logger "Result of cleaning: ""$?"
fi

# snippet 2
CNF_PTR=$(samba-tool dns query ${Server} ${revzone} @ ALL -k yes 2>/dev/null | grep -i -A 1 "${IP2add}" | grep -i -m 1 "CNF:" | awk -F "," '{print $1}')
 if [ -z "${CNF_PTR}" ]; then
logger "No CNF PTR entry found (=> no conflict). That's fine."
 else
logger "CNF PTR Record found. There was a conflict and should be cleaned up now."
logger "Record to delete from DNS: ${RZIP}.${IP2add}${CNF_UID}"
samba-tool dns delete ${Server} ${revzone} "${IP2add}"$'\n'"${CNF_PTR}" PTR "${name}".${domain} -k yes
logger "Result of cleaning: ""$?"
 fi

There are nicer solutions and I still hope that you can somehow determine the "responsibility" of the respective failover peer.

Have a nice day!



More information about the samba mailing list