User Tools

Site Tools


system:what_is_my_ip_address

This is an old revision of the document!


What's my source IP as seen from The Internet?

Example Usage:

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"
$ 
system/what_is_my_ip_address.1680162805.txt.bz2 · Last modified: 2023-03-30T07:53:25+0000 by michael_paoli