How can I find the public facing IP for my net work in Python?
+5
A:
This will fetch your remote IP address
import urllib
ip = urllib.urlopen('http://www.whatismyip.com/automation/n09230945.asp').read()
If you don't want to rely on someone else, then just upload something like this PHP script:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
and change the URL in the Python or if you prefer ASP:
<%
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
%>
Note: I don't know ASP, but I figured it might be useful to have here so I googled.
Unkwntech
2008-10-03 12:22:07
+3
A:
whatismyip.org is better... it just tosses back the ip as plaintext with no extraneous crap.
import urllib
ip = urllib.urlopen('http://whatismyip.org').read()
But yeah, it's impossible to do it easily without relying on something outside the network itself.
Steve Losh
2008-10-03 12:25:55
Neither does the link I reference, it also just returns the raw IP address.
Unkwntech
2008-10-03 12:31:26
A:
One way is , you can make a request to the page at
http://www.biranchi.com/ip.php
it returns the IP address of your system
Biranchi
2009-11-25 04:19:57