Skip to content

Instantly share code, notes, and snippets.

@PhirePhly
Created January 16, 2019 05:56
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 PhirePhly/ed5b6c20b21f6f16d1f7da980829b05c to your computer and use it in GitHub Desktop.
Save PhirePhly/ed5b6c20b21f6f16d1f7da980829b05c to your computer and use it in GitHub Desktop.
A shell script fragment to generate a BIND ACL from an IRR object
#!/bin/bash
#
# Using IRR and BGPQ3 to auto-generate BIND ACLs
# Kenneth Finnegan, 2019
# The IRR aut-num or as-set to generate the ACL off of
ACL_AS_SET='AS7034:AS-DNS'
(
bgpq3 -j -4 -l ACL $ACL_AS_SET;
bgpq3 -j -6 -l ACL $ACL_AS_SET;
) | \
# Parse out just the prefixes from the JSON
jq '.ACL[].prefix' | \
# Format it as a BIND ACL
awk -F '"' 'BEGIN {print "// BIND DNS ACL generated from IRR"}
BEGIN {print "acl \"serviceacl\" {" }
{print " " $2 ";"}
END {print "};"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment