view raw
hasen hasen - 10 months ago 71
Python Question

Discovering public IP programatically

I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)

Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it?

P.S. I'm planning on writing a short python script to do it


EDIT: is no longer available. (thanks maxywb)

Original Post:

As of writing this post, works. From the command line:


It's a third-party website, which may or may not be available a couple years down the road. But for the time being, it seems pretty simple and to the point.