How can I find the public facing IP for my net work in Python?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Reference
Try putting whatever 'findmyipsite' you can find into a list and iterating through them for comparison. This one seems to work well.
This will fetch your remote IP address
If you don't want to rely on someone else, then just upload something like this PHP script:
and change the URL in the Python or if you prefer ASP:
Note: I don't know ASP, but I figured it might be useful to have here so I googled.
https://api.ipify.org/?format=json is pretty straight forward
can be parsed by just running
requests.get("https://api.ipify.org/?format=json").json()['ip']
If you don't mind expletives then try:
http://wtfismyip.com/json
Bind it up in the usual urllib stuff as others have shown.
There's also:
http://www.networksecuritytoolkit.org/nst/tools/ip.php
All of the answers I see above would report the IP address of any web proxy in use, not necessarily the public facing IP address of your system (anything not being run through a web proxy may have an entirely different IP address).