📄 dns_update
字号:
#!/bin/sh## Example script for "wins hook". This attempts to update the DNS with# new A records for the NETBIOS name that Samba passes us. We do this# the simple way, by deleting all DNS records for the name and then# readding all the expected 'A' records.## Written by Stephen Rothwell <sfr@linuxcare.com>### Configurable things## The domain in which to create names# YOU MUST CHANGE THIS# N.B. include the trailing dot## It is a good idea to use a subdomain of your primary domain to ensure# that rogue machines can't take over (or delete) important names on# your network.DOMAIN=wins.example.com.## The DNS TTL to give the records (in seconds)#TTL=3600## NETBIOS name types that we want to create DNS records for:# 20 is server# 00 is workstation# 03 is user#USEFUL_TYPES="20 00 03"## The name of a cache file to use to avoid continual updates# of the same name and IP addresses. If you comment this out# then the cache is not kept at all.##CACHE_FILE=/usr/local/samba/var/wins_update.cacheif [ $# -lt 4 ]; then echo "Usage: $0 op name type ttl [ip_addr ...]" 1>&2 echo " op is one of add, refresh, delete" 1>&2 echo " name is the NETBIOS name" 1>&2 echo " type is the NETBIOS name type" 1>&2 echo " ttl is the NETBIOS time to live" 1>&2 echo " ip_addr's are the remaining IP addresses for this name" 1>&2 exit 1fiNSUPDATE=`which nsupdate`[ -x "$NSUPDATE" ] || NSUPDATE=/usr/bin/nsupdate[ -x "$NSUPDATE" ] || NSUPDATE=/sbin/nsupdate[ -x "$NSUPDATE" ] || NSUPDATE=/usr/sbin/nsupdate[ -x "$NSUPDATE" ] || { echo "Cannot find nsupdate." 1>&2 exit 1}OP=$1NAME=$2TYPE=$3WINS_TTL=$4shift 4IP_ADDRS="$@"do_update=0for i in $USEFUL_TYPESdo [ "$TYPE" = "$i" ] && do_update=1done[ $do_update = 1 ] || exit 0if [ -n "$CACHE_FILE" ]; then if [ -r "$CACHE_FILE" ]; then fgrep -q -x -i "$NAME $IP_ADDRS" "$CACHE_FILE" && exit 0 grep -v -i "^$NAME " "$CACHE_FILE" >"$CACHE_FILE".$$ fi echo "$NAME $IP_ADDRS" >>"$CACHE_FILE".$$ mv "$CACHE_FILE" "$CACHE_FILE".old 2>/dev/null mv "$CACHE_FILE".$$ "$CACHE_FILE"fi{ echo update delete $NAME.$DOMAIN for i in $IP_ADDRS do echo update add $NAME.$DOMAIN $TTL A $i done echo} 2>/dev/null | $NSUPDATE >/dev/null 2>&1 &exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -