aboutsummaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rwxr-xr-xcli/get-ip.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/cli/get-ip.sh b/cli/get-ip.sh
index 3bfc660..27da1cb 100755
--- a/cli/get-ip.sh
+++ b/cli/get-ip.sh
@@ -1,8 +1,12 @@
#!/bin/sh
#
-# Get the public IPv4 address.
+# Get the public IPv4 & IPv6 address.
#
# Credit:
+# * icanhaz:
+# - https://icanhazip.com
+# - https://major.io/icanhazip-com-faq/
+# - https://github.com/major/icanhaz
# * http://ifconfig.me/
# * http://ipecho.net/
#
@@ -11,8 +15,11 @@
# MIT license
#
-URL="http://ifconfig.me"
-URL="http://ipecho.net/plain"
+#URL="http://ifconfig.me" # IPv4 only
+#URL="http://ipecho.net/plain" # IPv4 only
+URL="https://icanhazip.com" # IPv4 & IPv6
-ip=$(curl -s ${URL})
-echo ${ip}
+ipv4=$(curl -4s ${URL} 2>/dev/null)
+ipv6=$(curl -6s ${URL} 2>/dev/null)
+[ -n "${ipv4}" ] && echo "IPv4: ${ipv4}"
+[ -n "${ipv6}" ] && echo "IPv6: ${ipv6}"