#!/bin/sh # # This is a shell script for performing TSIG-signed dynamic DNS updates # using "nsupdate". It needs BIND 9.2.2 or later # # All updates are in the form of a single "A" resource record, which needs # a domain name and its IP address # # You need to provide five parameters to invoke this shell script # # $1: TSIG key and secret in the form of key:secret # $2: operation string: either "add" or "delete" # $3: The hostname (FQDN) to be updated # $4: The IP address for the updated hostname # $5: the DNS server for sending updates (can be NULL). To improve # performance, you should provide this parameter # # (c) Columbia University, 2004-2006, All Rights Reserved. # Author: Weibin Zhao # bind_bin=/home/zwb/data1/bind/bin if [ $# -ne 5 ] then echo "Usage: $0 key:secret update_opstr host_name ip_address dns_server" exit -1 fi if [ $2 != "add" -a $2 != "delete" ] then echo "update_operation_string must be either add or delete" exit -1 fi set_server="" if [ $5 != "NULL" ] then set_server="server $5" fi if [ $2 = "add" ] then ${bind_bin}/nsupdate -y $1 <<-EOF ${set_server} update add $3 1800 in A $4 send EOF elif [ $2 = "delete" ] then ${bind_bin}/nsupdate -y $1 <<-EOF ${set_server} update delete $3 A $4 send EOF fi