Poor man’s ddns in AD environment for Linux

Somewhere, something is busted and my sssd is not keeping the dynamic dns entries for my statically assigned IP addresses in Microsoft DNS. So I threw together a cronjob for this script

#!/bin/sh
# Poor man's ddns
# Because AD keeps losing the dns record for my dhcp ip address
# reference: https://bgstack15.wordpress.com/2018/04/15/wrapper-script-for-ansible-to-use-nsupdate-with-gsstsig/

IPADDR=$( ip -o a s | awk '$1 !~ /lo/ && $2 !~ /lo/' | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}\/[0-9]+' | awk -F'/' '{print $1}' )
RR=$( echo ${IPADDR} | tr '.' '\n' | tac | tr '\n' '.' )in-addr.arpa

$( which kinit-host )

nsupdate <<EOF
update add ${HOSTNAME}. 86400 A ${IPADDR}
send
gsstsig
update add ${RR} 300 IN PTR ${HOSTNAME}.
send
EOF

Obviously this depends on kinit-host (from bgscripts package)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.