Skip to content

Instantly share code, notes, and snippets.

@dansimau
Last active April 28, 2022 08:44
Show Gist options
  • Save dansimau/0c37f2e24abebe97191de032286558d6 to your computer and use it in GitHub Desktop.
Save dansimau/0c37f2e24abebe97191de032286558d6 to your computer and use it in GitHub Desktop.
Recursively return all SPF includes for a given domain
spfincludelookup() { for entry in $(dig +short TXT "$@" |grep --color=never spf); do [ "${entry:0:7}" == "include" -o "${entry:0:6}" == "exists" ] && echo $entry && spfincludelookup ${entry:8}; done; }
spfincludelookup "$@"
@dansimau
Copy link
Author

Usage:

$ spfincludelookup google.com
include:_spf.google.com
include:_netblocks.google.com
include:_netblocks2.google.com
include:_netblocks3.google.com

Count number of records (should be less than the SPF spec limit of 10):

$ spfincludelookup google.com | wc -l
       4

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