Last active
January 11, 2019 10:23
-
-
Save mjf/5300328 to your computer and use it in GitHub Desktop.
Simple IPv6 PTR helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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