Avatar photoTelium Support Group
Participant
Post count: 262

First you must enable insecure updates on your Windows DNS server as follows:

  1. Click Start, point to Administrative Tools, and then click DNS.
  2. Under DNS, double-click the applicable DNS server, double-click Forward Lookup Zones
  3. Right-click the applicable zone.
  4. Click Properties.
  5. In the Dynamic updates box, click to allow insecure updates
  6. Repeat the above for the associated reverse lookup zone
  7. Click OK.

Next, you need to add some code to your Asterisk pre-start event handler to update the DNS entries:


#!/bin/bash
# Update DNS server with this IP 192.x.x.x address
HOST=pbx.mydomain.local
IP=$(ip addr | grep 192 | awk ‘{print $2}’ | cut -f 1 -d/)
TTL=600
SERVER1=192.168.0.2
SERVER2=192.168.1.2
#—————————————————————————-
NSU=/tmp/nsupdate.data
echo “server ${SERVER1}” > ${NSU}
echo “update delete $HOST A” >> ${NSU}
echo “update add $HOST ${TTL} A ${IP}” >> ${NSU}
echo “update delete $HOST PTR” >> ${NSU}
echo “update add $HOST ${TTL} PTR ${IP}” >> ${NSU}
echo “send” >> ${NSU}
logger “asterisk.start.pre updating DNS for host ${HOST} to IP ${IP} on server ${SERVER1}”
nsupdate -v ${NSU}
echo “server ${SERVER2}” > ${NSU}
echo “update delete $HOST A” >> ${NSU}
echo “update add $HOST ${TTL} A ${IP}” >> ${NSU}
echo “update delete $HOST PTR” >> ${NSU}
echo “update add $HOST ${TTL} PTR ${IP}” >> ${NSU}
echo “send” >> ${NSU}
logger “asterisk.start.pre updating DNS for host ${HOST} to IP ${IP} on server ${SERVER2}”
nsupdate -v ${NSU}
rm -f ${NSU}