How to get your current IPv4 address using wget

Also see How to get your current IPv6 address using wget

Use

wget -qO- https://ipv4.techoverflow.net/api/get-my-ip

which uses the TechOverflow get-my-ip API.

Example:

$ wget -qO- https://ipv4.techoverflow.net/api/get-my-ip
80.138.203.18

Prefer a JSON response?

Use https://ipv4.techoverflow.net/api/get-my-ip-json instead:

wget -qO- https://ipv4.techoverflow.net/api/get-my-ip-json

Example:

$ wget -qO- https://ipv4.techoverflow.net/api/get-my-ip-json
{"ip": "80.138.201.17"}

Want this API on your own server? Check out How to make your own ‘get my current IP address’ server using only nginx