Skip to content

Instantly share code, notes, and snippets.

@tacitochaves
Last active August 29, 2015 14:02
Show Gist options
  • Save tacitochaves/84c4e486d76cf8c8b35d to your computer and use it in GitHub Desktop.
Save tacitochaves/84c4e486d76cf8c8b35d to your computer and use it in GitHub Desktop.
nsupdate.sh
#!/bin/bash
#
# nsupdate.sh
#
# Script para inserir endereços dinâmicos no servidor de DNS.
# variáveis de ambiente
KEYNAME="server"
HASH="J+fO2y2XYAVhlBSExwF7Bz/07fMd849Cnq3C+8QhuVr+C5imEig9qBUv8HBFHqccXIJ3GFJXRZnkX/0XCkzBng=="
SERVER="ns1.tchaves.com.br"
ZONE="din.tchaves.com.br"
HOST="chaves.din.tchaves.com.br"
# descobrir o IP atual da interface dinâmica
IP=$1
# definir comando de update
NSUPDATE="/usr/bin/nsupdate -y $KEYNAME:$HASH"
# conteúdo a ser enviado ao servidor
EXEC="server $SERVER\n
zone $ZONE\n
update delete $HOST A\n
update add $HOST 60 A $IP\n
send"
# executar a atualização
echo -e $EXEC | $NSUPDATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment