Skip to content

Instantly share code, notes, and snippets.

@kaimi
Last active December 16, 2015 05:09
Show Gist options
  • Select an option

  • Save kaimi/5382618 to your computer and use it in GitHub Desktop.

Select an option

Save kaimi/5382618 to your computer and use it in GitHub Desktop.
What’s my IP?
#!/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
@kaimi
Copy link
Author

kaimi commented Apr 14, 2013

myip.cn returns the IP address in plain text and doesn’t retrieve it via some shitty javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment