Skip to content

Instantly share code, notes, and snippets.

@brimston3
Created September 21, 2013 20:47
Show Gist options
  • Save brimston3/6654030 to your computer and use it in GitHub Desktop.
Save brimston3/6654030 to your computer and use it in GitHub Desktop.
Awk script to convert from a list of IPv4s and hostnames to a zonefile format rdns entry.
awk '{print gensub(/([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*) - (.*)/,"\\4.\\3.\\2.\\1.in-addr.arpa. IN PTR \\5.", $0)}' << "EOF"
192.168.1.101 - test.localdomain
192.168.1.105 - test2.example.com
EOF
@brimston3
Copy link
Author

Probably lower resource usage in sed, but awk is more familiar.

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