Skip to content

Instantly share code, notes, and snippets.

@metalefty
Last active June 1, 2017 13:35
Show Gist options
  • Select an option

  • Save metalefty/e2112eee04b0097d108737072a69b4ce to your computer and use it in GitHub Desktop.

Select an option

Save metalefty/e2112eee04b0097d108737072a69b4ce to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# The MIT License (MIT) https://opensource.org/licenses/MIT
# Copyright (c) 2016 Koichiro IWAO <meta@vmeta.jp>
if [ -z "$1" ]; then
echo "Usage: $0 interface" 1>&2
exit 1
fi
# if you want global ip addr
#IP4ADDR=$(curl http://checkip.amazonaws.com)
IP4ADDR=$(ip -o -4 addr show dev ${1} | awk -F '[ /]+' '/global/ {print $4}')
IP6ADDR=$(ip -o -6 addr show dev ${1} | awk -F '[ /]+' '/global/ {print $4}')
if [ -z "${IP4ADDR}" ]; then
cli53 rd "$(hostname -d)" "$(hostname -s)" A
else
cli53 rc --replace "$(hostname -d)" "$(hostname -s) 60 A ${IP4ADDR}"
fi
if [ -z "${IP6ADDR}" ]; then
cli53 rd "$(hostname -d)" "$(hostname -s)" AAAA
else
cli53 rc --replace "$(hostname -d)" "$(hostname -s) 60 AAAA ${IP6ADDR}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment