This shows you the differences between two versions of the page.
Next revision Both sides next revision | |||
system:what_is_my_ip_address [2022-06-07T03:25:38+0000] michael_paoli created |
system:what_is_my_ip_address [2022-06-07T04:00:50+0000] michael_paoli +Example Usage |
||
---|---|---|---|
Line 19: | Line 19: | ||
| - | - | 4 | 6 | y |@resolver1.opendns.com. myip.opendns.com. A myip.opendns.com. AAAA | | | - | - | 4 | 6 | y |@resolver1.opendns.com. myip.opendns.com. A myip.opendns.com. AAAA | | ||
| - | - | 4 | - | y |@dns.toys ip. TXT # @dns.toys help. TXT # https://www.dns.toys/ | | | - | - | 4 | - | y |@dns.toys ip. TXT # @dns.toys help. TXT # https://www.dns.toys/ | | ||
+ | |||
+ | ===== Example Usage: ===== | ||
+ | |||
+ | <file> | ||
+ | for path in \ | ||
+ | ifconfig.co/ \ | ||
+ | icanhazip.com/ \ | ||
+ | ipinfo.io/ip \ | ||
+ | ifconfig.me/ \ | ||
+ | api.ipify.org/ \ | ||
+ | echoip.xyz/ \ | ||
+ | www.{,ipv{4,6}.}balug.org/myip \ | ||
+ | whatismyip.akamai.com/ | ||
+ | do | ||
+ | for scheme in http https | ||
+ | do | ||
+ | for v in 4 6 | ||
+ | do | ||
+ | r=$(curl -s -"$v" "$scheme://$path") | ||
+ | if expr x"$r" : x'[.0-9:A-Za-z]\{1,\}$' >>/dev/null; then | ||
+ | echo "\$ curl -s -$v $scheme://$path" | ||
+ | echo $r | ||
+ | elif [ "$scheme" = https ]; then | ||
+ | r=$(curl -k -s -"$v" "$scheme://$path") | ||
+ | expr x"$r" : x'[.0-9:A-Za-z]\{1,\}$' >>/dev/null && | ||
+ | { | ||
+ | echo "\$ curl -k -s -$v $scheme://$path" | ||
+ | echo $r; | ||
+ | } | ||
+ | fi | ||
+ | done | ||
+ | done | ||
+ | done; echo '$ ' | ||
+ | |||
+ | $ curl -s -4 http://ifconfig.co/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -6 http://ifconfig.co/ | ||
+ | 2001:470:67:76f::2 | ||
+ | $ curl -s -4 https://ifconfig.co/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -6 https://ifconfig.co/ | ||
+ | 2001:470:67:76f::2 | ||
+ | $ curl -s -4 http://icanhazip.com/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -6 http://icanhazip.com/ | ||
+ | 2001:470:67:76f::2 | ||
+ | $ curl -s -4 https://icanhazip.com/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -6 https://icanhazip.com/ | ||
+ | 2001:470:67:76f::2 | ||
+ | $ curl -s -4 http://ipinfo.io/ip | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 https://ipinfo.io/ip | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 http://ifconfig.me/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 https://ifconfig.me/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 http://api.ipify.org/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 https://api.ipify.org/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 https://echoip.xyz/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -s -4 http://whatismyip.akamai.com/ | ||
+ | 96.86.170.226 | ||
+ | $ curl -k -s -4 https://whatismyip.akamai.com/ | ||
+ | 96.86.170.226 | ||
+ | $ | ||
+ | |||
+ | for ns_rr_t_t2 in \ | ||
+ | 'ns1.google.com. o-o.myaddr.l.google.com. TXT' \ | ||
+ | 'resolver1.opendns.com. myip.opendns.com. A AAAA' \ | ||
+ | 'dns.toys ip. TXT' | ||
+ | do | ||
+ | set -- $ns_rr_t_t2; NS="$1"; RR="$2"; TYPE="$3"; TYPE2="$4" | ||
+ | query="$RR $TYPE${TYPE2:+ $RR $TYPE2}" | ||
+ | for v in 4 6 | ||
+ | do | ||
+ | r=$(dig @"$NS" +short +norecurse -"$v" $query 2>>/dev/null) && | ||
+ | [ -n "$r" ] && { | ||
+ | echo \$ dig @"$NS" +short +norecurse -"$v" $query | ||
+ | echo $r | ||
+ | } | ||
+ | done | ||
+ | : | ||
+ | done; echo '$ ' | ||
+ | |||
+ | $ dig @ns1.google.com. +short +norecurse -4 o-o.myaddr.l.google.com. TXT | ||
+ | "96.86.170.226" | ||
+ | $ dig @ns1.google.com. +short +norecurse -6 o-o.myaddr.l.google.com. TXT | ||
+ | "2001:470:67:76f::2" | ||
+ | $ dig @resolver1.opendns.com. +short +norecurse -4 myip.opendns.com. A myip.opendns.com. AAAA | ||
+ | 96.86.170.226 | ||
+ | $ dig @resolver1.opendns.com. +short +norecurse -6 myip.opendns.com. A myip.opendns.com. AAAA | ||
+ | 2001:470:67:76f::2 | ||
+ | $ dig @dns.toys +short +norecurse -4 ip. TXT | ||
+ | "96.86.170.226" | ||
+ | $ | ||
+ | </file> |