Skip to content

Instantly share code, notes, and snippets.

@mjf
Last active January 11, 2019 10:23
Show Gist options
  • Save mjf/5300328 to your computer and use it in GitHub Desktop.
Save mjf/5300328 to your computer and use it in GitHub Desktop.
Simple IPv6 PTR helper
#! /bin/sh
# ip6rev - Generate IPv6 PTR DNS RR
# Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of "The MIT License"
if [ $# -lt 1 -o -$# -gt 3 ]; then
cat <<- EOT
ip6rev ip6 rev [oct]
Where:
ip6 IPv6 address
rev Hostname
oct Octets (optional; default: 20)
EOT
else
pfx=$(
sipcalc -r "$1" |
sed -n 5p |
cut -d. -f1-"${3:-20}"
)
printf '%s\tIN\tPTR\t%s\n' "$pfx" "${2%.}."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment