Skip to content

Instantly share code, notes, and snippets.

@bortzmeyer
Created June 20, 2017 11:47
Show Gist options
  • Save bortzmeyer/6c9065fce3cd4c33e532770b18503d02 to your computer and use it in GitHub Desktop.
Save bortzmeyer/6c9065fce3cd4c33e532770b18503d02 to your computer and use it in GitHub Desktop.
Get the AS (IPv4 only) froma DNS request
bgproute () {
	if [ -z "$1" ]
	then
		echo "Usage: bgproute IP-address"
		return 1
	fi
	dig +short TXT `echo $1 |                awk -F. '{print $4 "." $3 "." $2 "." $1 ".aspath.routeviews.org" }'` | awk -F\" '{print "AS path: " $2 "\nRoute: " $4 "/" $6}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment