Getting your public IP address from the command-line
Posted by jpluimers on 2016/01/13
Many sites giving your public IP address return a web page with a bloat of html. From the command-line, you are usually only interested in the IP-address itself. Few services return exactly that.
Below are command-line examples to provide the public IP address mostly from a *nix perspective. Usually you can get similar commands to work with Windows binaries for wget and Windows binaries for curl.
- Mac / *nix:
I’ve not tried aria2 yet, but might provide commands for that in the future.
These are the Linux permutations for akamai:
curl whatismyip.akamai.com && echo curl ipv4.whatismyip.akamai.com && echo curl ipv6.whatismyip.akamai.com && echo curl ipv4.whatismyip.akamai.com && echo && curl ipv6.whatismyip.akamai.com && echo
These get you plain text:
- curl whatismyip.akamai.com
- curl ipv4.whatismyip.akamai.com
- curl ipv6.whatismyip.akamai.com
- curl icanhazip.com
- curl ipv4.icanhazip.com
- curl ipv6.icanhazip.com
- curl ident.me
- curl v4.ident.me
- curl v6.ident.me
- curl ipecho.net/plain
- curl ifconfig.me/ip
- curl ipogre.com
- curl ipv4.ipogre.com
- curl ipv6.ipogre.com
- curl bot.whatismyipaddress.com
- telnet myip.gelma.net
These get slightly more, but not much more than the plain IP address:
- curl ident.me/.json
- curl ident.me/.xml
- curl ident.me/.html
- curl ifconfig.me/all.json
- curl checkip.dyndns.org
Thanks to these links that helped me find out about the above services.
- ident.me API
- Show my IP address.
- IP Ogre | Linux Command Line.
- IP Echo Service – Get IP Address programatically.
- networking – Command for determining my public IP? – Ask Ubuntu.
- What is my public IP | Linux.
- Linux: Get IP Address on Command Line/Shell (internal/external).
- What Is My IP Address? – ifconfig.me.
- NTLM and Kerberos Authentication for a WebRequest and a WebProxy.
If you ever want to run your own Dynamic DNS service (DDNS): http://andrwe.org/linux/own-ddns