Home Forums HAast (High Availability for Asterisk) Configuration & Optimization Update DNS record to point to active PBX

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Avatar photoCustomer Inquiry
    Member
    Post count: 197

    I have 2 DNS servers (192.168.0.2 and 192.168.1.2) and I would like them to automatically resolve ‘pbx.mydomain.com’ to the IP of the active cluster member.

    As well, I would like reverse (PTR) resolution to also reflect the active server.

    And I use Windows Server 2016 for my DNS services.

    How can I do this?

    Avatar photoTelium Support Group
    Member
    Post count: 258

    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}

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.