So for example if you're on an remote server and want to check the public IP address you could go for an ifconfig and if you have an public IP this works. But if you're behind an NAT or something you need something else. I just use:

  • Check up via commandline: curl checkip.amazonaws.com

There are other services:

curl checkip.amazonaws.com
curl ifconfig.me
curl icanhazip.com

This you could use in an Webhook or something to Mail you the current Ip Address (for example if you don't want to use dyndns or something)

Icanhazip.com delivers your IPv6 Address if you have one. http://icanhazip.com/

Amazon Checkup delivers your IPv4 Address. checkip.amazonaws.com/

Ifconfig.me delivers your IPv4 Address when used with curl https://ifconfig.me/

With Ifconfig.me you also get an more advanced api, for example:

  • Get the header from your http request: curl ifconfig.me/ua

You also get a machine readable json with all the meta data like this:

  • curl ifconfig.me/all.json

This is how you get your IP with Python

In Python your ifconfig.me request:

import json
import requests

url = "http://ifconfig.me/all.json"

r = requests.get(url)

response = json.loads(r.text)

print(response['ip_addr'])
print(response['user_agent'])