Last active
April 1, 2025 07:55
-
-
Save venam/13e00e5a3ceb9ca779be291170b53102 to your computer and use it in GitHub Desktop.
tracepath with geoloc
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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <destination>" | |
exit 1 | |
fi | |
destination=$1 | |
stdbuf -oL tracepath -n $destination | while read line; do | |
ip=$(echo $line | grep -oP '\d+\.\d+\.\d+\.\d+') | |
if [[ -n $ip ]]; then | |
curl -s "https://ipinfo.io/$ip/json" | jq -r --arg line "$line" '"\($line) - City: \(.city), Country: \(.country)"' | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment