I've found the following command to get your current public IP that works well from command line:
nslookup myip.opendns.com resolver1.opendns.com
I want to be able to run a command though that JUST prints the resulant IP. (Right now it shows the specified DNS server and it's IP along with all the other info IE:
Server: resolver1.opendns.com
Address: 208.67.222.222
Non-authoritative answer:
Name: myip.opendns.com
Address: 123.123.123.123
I want it to just output:
123.123.123.123
Not sure if the is a command line flag to get what I want or if I can use some command line trickery to get just the output I want (ultimately, I want to redirect the output to a file, "> filename.txt"
Best Answer
Nslookup with A record IP as sole output
Assuming you are using Windows, this can be done using a simple one line command.
From the command line:
From a batch file:
Notes:
ip.txt
).PowerShell
,.Net
orawk
.Further Reading