Created
May 13, 2015 16:43
-
-
Save azet/0bbae876f75a48c87265 to your computer and use it in GitHub Desktop.
get a SPF record based on an IP address, if possible
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
| #!/usr/bin/env bash | |
| # | |
| # checks if a SPF record is present for a given IP | |
| # if that IP resolves for the MX and is used without | |
| # redirects/load balacing etc. | |
| # | |
| # needs to be improved | |
| # | |
| readonly IP=${1} | |
| function get_pointer() { | |
| local pointer=$(dig -x "${IP}" +short) | |
| printf "%s\n" ${pointer%.} | |
| } | |
| function main() { | |
| local pointer=$(get_pointer) | |
| [[ -z ${pointer} ]] && return 1 | |
| local txt=$(dig TXT "${pointer}" +short) | |
| [[ ${txt} =~ "spf" ]] || return 1 | |
| echo ${txt} | |
| } | |
| main | |
| #EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment