[KLUG Members] Samba wins-to-dns
Peter Buxton
members@kalamazoolinux.org
Tue, 20 Aug 2002 04:12:50 -0400
--gKMricLos+KVdGMg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Aug 20, 2002 at 01:44:14AM -0400, Peter Buxton wrote:
> Also, the script doesn't seem to use the add/refresh/delete commands
> given to it by Samba, either. Hmmmm.
Okay, this is undoubtedly another stupid nsupdate trick. How do I tell
nsupdate to only give updates to localhost? "server localhost" sure as
heck wasn't it. :-(
TIA, Adam,
Peter
#!/bin/bash
PATH=3D"/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"
DOMAIN=3D"caresswm.org."
TTL=3D"3600" # The DNS TTL to give the records (in seconds)
USEFUL_TYPES=3D"03" # NETBIOS name types that we want to create DNS=20
# records for. 20 server, 00 workstation, 03 user=20
# 1b workgroup? 1c server?
NSUPDATE=3D`which nsupdate` || {
echo "Cannot find nsupdate in \$PATH $PATH." 1>&2
exit 1
}
if [ $# -lt 4 ]
then
echo -e "Usage: $0 op name type ttl [ip_addr ...]\n op is one of" \
"add, refresh, delete\n name is the NETBIOS name\n type is the" \
"NETBIOS name type\n ttl is the NETBIOS time to live\n ip_addr's" \
"are the remaining IP addresses for this name" 1>&2
exit 1
fi
function nbdel_fromdns {
{
for i in `dig +short $NAME.$DOMAIN`
do REVVED=3D""
for d in 4 3 2 1
do REVVED=3D${REVVED}`echo $i | cut -f$d -d.`.
done
echo "update delete ${REVVED}in-addr.arpa"
done
echo -e "update delete $NAME.$DOMAIN\n"
} 2> /dev/null | $NSUPDATE > /dev/null 2>&1
return 0
}
function nbadd_todns {
{
for i in $IP_ADDRS
do echo "update delete $NAME.$DOMAIN"
echo "update add $NAME.$DOMAIN $TTL A $i"
REVVED=3D""
for d in 4 3 2 1
do REVVED=3D${REVVED}`echo $i | cut -f$d -d.`.
done
echo "update delete ${REVVED}in-addr.arpa"
echo "update add ${REVVED}in-addr.arpa $TTL IN PTR $NAME.$DOMAIN"
done
echo
} 2> /dev/null | $NSUPDATE > /dev/null 2>&1
return 0
}
OP=3D$1 ; NAME=3D$2 ; TYPE=3D$3 ; WINS_TTL=3D$4
shift 4
IP_ADDRS=3D"$@"
do_update=3D0
for i in $USEFUL_TYPES
do
if [ "$TYPE" =3D "$i" ]
then
if [ "$OP" =3D "delete" ]
then
nbdel_fromdns
else
nbadd_todns
fi
fi
done
exit 0
--=20
http://www.killdevil.org/~peter (/gpg.html)
on R.Fripp, "Rock's gain of an eccentric, idiosyncratic
musician is industry's loss of a great economist."
--gKMricLos+KVdGMg
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9YfoBaAK8ZwqLoskRAuBgAJ4pkJPMtZUat961OeAfyB0zIxlCtQCaA6f7
OkPaY+Ws0qLByMGu3RVgUCE=
=B9/7
-----END PGP SIGNATURE-----
--gKMricLos+KVdGMg--