#!/bin/bash
#
# Update your Dynamic IP by using BIND 9 's tools
#
###############################################
# History
# 2004/10/27 VBird First time release
#
##############################################
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH

# 0. keyin your parameters
basedir="/usr/local/ddns"                                                # working directory
keyfile="$basedir"/"Kweb.+157+29323.key"                 # your ddns' key (filename)
ttl=600                                                                            # the ttl time ( 10 min. )
outif="ppp0"                                                                   # Your interface (to internet)
hostname="web.ssorc.tw"                                       # Your hostname
servername="203.204.2.104"                                         # The primary DNS server

# Get your new IP
newip=`ifconfig "$outif" | grep 'inet addr' |
                      awk '{print $2}' | sed -e "s/addr://"`
checkip=`echo $newip | grep "^[0-9]"`
if [ "$checkip" == "" ]; then
                      echo "$0: The interface can't connect internet…."
                      exit 1
fi

# create the temporal file
tmpfile=$basedir/tmp.txt
cd $basedir
echo "server $servername"                              > $tmpfile
echo "update delete $hostname A "                 >> $tmpfile
echo "update add $hostname $ttl A $newip"   >> $tmpfile
echo "send"                                                     >> $tmpfile

# send your IP to server
nsupdate -k $keyfile -v $tmpfile

Related posts 相關文章

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。