Skip to content

Instantly share code, notes, and snippets.

@jpmens

jpmens/mk-ptr.py Secret

Last active October 21, 2020 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmens/3aac1fcedb788f43deb8ed36ccf75443 to your computer and use it in GitHub Desktop.
Save jpmens/3aac1fcedb788f43deb8ed36ccf75443 to your computer and use it in GitHub Desktop.
Generate catalog zone PTR records
#!/usr/local/bin/python3.7
# Jan-Piet Mens, 2020-OCT-21
import dns.name # pip install dnspython
import hashlib
import sys
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: {0} domain-name [domain-name ..]".format(sys.argv[0]), file=sys.stderr)
exit(2)
for domain in sys.argv[1:]:
fqdn = dns.name.from_text(domain)
h = hashlib.sha1(dns.name.from_text(domain).to_wire()).hexdigest()
print("{0}.zones\t\tPTR {1}".format(h, fqdn))
@jpmens
Copy link
Author

jpmens commented Oct 21, 2020

$ mk-ptr.py example.com example.org
c5e4b4da1e5a620ddaa3635e55c3732a5b49c7f4.zones          PTR example.com.
47ac1a4d93b61fffdb4762c18c9e7d1a6b046d33.zones          PTR example.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment