Roberto de Sousa wrote:
Hello Henri,
Thank you for your kindness to help me on this.. I have generated the key and and edit my named.conf as per your instruction. I have also tried your script which work great. What i would like to find out more is that how to modify this script so that it provides flexibility without having to specify the host in the script? what i mean is that.. i could select add or delete option from CLI and able to add any host to forward & Reversing Zone of my DNS from my freeBSD CLI?

<--- clip --->

What do you thing about the attached script ? Some more check of args may be usefull ...

Henri
#!/bin/sh
usage () {
    echo 'Usage: dnsupdate -a|-d|-u <HostName>=<IP_Address>'
    echo '      -a      add DNS entry for <HostName>'
    echo '      -d      delete DNS entry for <HostName>'
    echo '      -u      update DNS entry<HostName>'
}
NSSERVER='xxx.xxx.xxx.xxx'
TSIG='host1.example.com.:XXXX...XXXX=='
#-------------------------
case $# in
    2)  ;;
    *)  usage >&2;
        exit 1;;
esac
HOSTNAME=${2%%=*}
IPADDR=${2##*=}
if [ ${HOSTNAME} = $2 -o ${IPADDR} = $2 ]
then
   usage >&2;
   exit 1
fi
IPADDR1=${IPADDR%%.*}
IPADDRX=${IPADDR#*.}
IPADDR2=${IPADDRX%%.*}
IPADDRX=${IPADDRX#*.}
IPADDR3=${IPADDRX%%.*}
IPADDR4=${IPADDRX#*.}
if [ "${IPADDR1}.${IPADDR2}.${IPADDR3}.${IPADDR4}" != ${IPADDR} ]
then
    usage >&2;
    exit 1
fi
delete() {
echo update delete ${HOSTNAME}. IN A
echo update delete ${IPADDR4}.${IPADDR3}.${IPADDR2}.${IPADDR1}.in-addr.arpa. IN 
PTR
}
add() {
echo update add ${HOSTNAME}. 60 IN A ${IPADDR}
echo update add ${IPADDR4}.${IPADDR3}.${IPADDR2}.${IPADDR1}.in-addr.arpa. 60 IN 
PTR ${HOSTNAME}.
}
case $1 in
    -a|-d|-u) ;;
    *)  usage >&2;
        exit 1;;
esac
case $1 in
    -a) echo server ${NSSERVER};
        add;
        echo send;;
    -d) echo server ${NSSERVER};
        delete;
        echo send;;
    -u) echo server ${NSSERVER};
        delete;
        add;
        echo send;;
esac | /usr/bin/nsupdate -y ${TSIG} 1>/dev/null
_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to