I tried using nslookup but I'm unable to parse the result :
My current output :
nslookup -norecurse myip.opendns.com resolver1.opendns.com
Serveur : resolver1.opendns.com
Address: 208.67.222.222
Réponse ne faisant pas autorité :
Nom : myip.opendns.com
Address: X.X.X.X
I just want the IP X.X.X.X
I tried using | select
without any success, maybe the good way, or not ...
Thanks for your help, note that the goal is just to get my public ip in a easy way without any dependancies and quickly, an answer without nslookup or powershell can make the job.
Try something like
Resolve-DnsName myip.opendns.com -server resolver1.opendns.com -type A | select -expand IP4Address
You can also use one of the many free REST APIs that provide this information rather than making DNS query (which has the downside of not working if you don't use dynamic DNS). Here's an example for one of the first ones I found.