]> git.rmz.io Git - dotfiles.git/commitdiff
bin: use dig for getting ip
authorSamir Benmendil <me@rmz.io>
Tue, 19 Jul 2016 22:47:54 +0000 (23:47 +0100)
committerSamir Benmendil <me@rmz.io>
Tue, 19 Jul 2016 22:47:54 +0000 (23:47 +0100)
it's very fast and will always work(tm)

bin/whatsmyip

index 8f6cbc77ce7b657c4c1d22268ca05cccc94841a0..2e6c6c39d4b3ff258d6e931b13ce6efc1b192e61 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/bash
-# only works behind DD-WRT router
-#ssh root@192.168.1.3 -p 2222 -q "nvram get wan_ipaddr"
-curl -s ifconfig.me/ip
+
+if hash dig 2>/dev/null; then
+    dig +short myip.opendns.com @resolver1.opendns.com
+elif hash curl 2>/dev/null; then
+    curl -s ifconfig.me/ip
+fi