-
-
Save mikewebkist/8959625 to your computer and use it in GitHub Desktop.
Get public IP addresses for all interfaces
This file contains 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 | |
for ipinterface in `netstat -rn | awk '/^default/ { printf("%s-%s\n", $2, $NF) }'`; do | |
interface="${ipinterface##*-}" | |
ip="${ipinterface%%-*}" | |
echo -n "$interface " | |
case "${ip//[^\:\.]/}" in | |
'...') | |
curl -4 --interface $interface icanhazip.com ;; | |
':::::') | |
curl -6 --interface $interface icanhazip.com ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment