I know that a lot of VPN users have it as a homepage to their browser, that is why I wanted to publish this warning.

You can replace it with:

you are viewing a single comment's thread
view the rest of the comments
[–] 3 points 7 months ago* (last edited 7 months ago) (10 children)
#!/usr/bin/sh  
dig -4 +short @resolver2.opendns.com myip.opendns.com  
#!/usr/bin/pwsh  
Resolve-DnsName -Server resolver2.opendns.com -Name myip.opendns.com -Type A | % { echo $_.IPAddress }  

There should be an IPv6 resolver, but I don't remember and am currently unable to test. My PowerShell skills are also effectively non-existent.

  • source
  • hideshow 10 child comments
  • [–] 3 points 7 months ago (5 children)

    A simpler and easy to memorize alternative:

    curl ifconfig.me
    
  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 7 months ago* (3 children)

    I saw it used in another comment, and am already aware of the use of curl for such a task, but choose to query DNS services instead—especially in scripts.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 7 months ago (2 children)

    but choose to query DNS services instead—especially in scripts.

    Why? What advantages do you get?

  • source
  • parent
  • hideshow 2 child comments
  • [–] 7 points 7 months ago*

    In order to connect to a site like wtfismyip.com you have to do a dns query for the IP address of the server, then query the http port on that IP address, but what if instead, that first dns query gave the answer to your question?

  • source
  • parent
  • [–] 1 point 7 months ago (3 children)

    Neat, how can you check IPv6? I was able to get my IPv4 address by querying with an A record, but tried with AAAA which doesn't respond with an answer.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 7 months ago* (last edited 7 months ago) (2 children)

    dig -6 +short @resolver2.opendns.com myip.opendns.com AAAA

    Note: You have to ensure you are actually contacting the server with IPv6.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 7 months ago (1 child)

    Ahh yeah, works with @resolver2.opendns.com so I guess my DNS resolver isn't supporting IPv6 or something like that?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 7 months ago* (last edited 7 months ago)

    This is a service provided by some DNS hosts, with their own special subdomains, and is not universal. They may also require slightly different options.

    Other options include:

    • Google (query for txt record): @ns1.google.com o-o.myaddr.l.google.com

    • Akaimai (query for txt record): @ns1-1.akamaitech.net whoami.akamai.net

    • Cloudflare: @1.1.1.1 whoami.cloudflare

    • Cisco (there are four, as far as can tell): @resolver[1-4].opendns.com myip.opendns.com

    …and likely others.

  • source
  • parent