Skip to content

Instantly share code, notes, and snippets.

@silenvx
Last active April 17, 2016 02:58
Show Gist options
  • Save silenvx/15d58473c201f1b7a2563cb2a09a3059 to your computer and use it in GitHub Desktop.
Save silenvx/15d58473c201f1b7a2563cb2a09a3059 to your computer and use it in GitHub Desktop.
DDNS update
#!/bin/sh
GLOBAL_IP=` echo $SSH_CONNECTION|cut -f1 -d " "`
HOST_NAME="sub.noter.jp"
TTL="3600"
echo $GLOBAL_IP|grep -E '^((([0-1]?[0-9]|2[0-4])?[0-9]|25[0-5])\.){3}(([0-1]?[0-9]|2[0-4])?[0-9]|25[0-5])$' > /dev/null
if [ $? -eq 0 ];then
echo "
server 127.0.0.1
update delete $HOST_NAME
update add $HOST_NAME $TTL A $GLOBAL_IP
send
"|nsupdate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment