Last active
December 16, 2015 05:09
-
-
Save kaimi/5382618 to your computer and use it in GitHub Desktop.
What’s my IP?
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 | |
| ipv4=`curl -s4 checkip.dns.he.net | grep -Po '(\d+\.){3}\d+'` | |
| if [ $ipv4 ] ; then | |
| echo "IPv4: ${ipv4}" | |
| else | |
| echo "no IPv4 address detected" | |
| fi | |
| ipv6=`curl -s6 checkip.dns.he.net | grep -Po '\d[\da-f\:]+'` | |
| if [ $ipv6 ] ; then | |
| echo "IPv6: ${ipv6}" | |
| else | |
| echo "no IPv6 address detected" | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
myip.cn returns the IP address in plain text and doesn’t retrieve it via some shitty javascript.