#!/bin/bash if [ -z "$1" -o "$1" == " " ]; then echo "usage: add_new_host.sh " echo "EXAMPLE: add_new_host.sh myhost will add myhost.dyn.mydomain.ch" exit 1 fi cd /etc/bind/dyn/ hostname=${1}.dyn.mydomain.ch. echo "generating key for ${hostname}" key=$(tsig-keygen -a hmac-md5 ${hostname}) echo "here is the HMAC-MD5 key i have generated, use this to configure your client:" echo "-----------------8<--------------" echo "${key}" | grep "secret" | awk -F '"' '{print $2}' echo "-----------------8<--------------" echo "add key to bind config" echo $(echo "$key" | tr -d "\r\n") >> keys.conf echo "reload bind"; /usr/sbin/rndc reload echo "currently active hosts:" grep "key " keys.conf | awk '{ print $2; }' | tr -d ";"