How can I find the public facing IP for my net work in Python?
Advertisement
Answer
This will fetch your remote IP address
JavaScript
x
3
1
import urllib
2
ip = urllib.urlopen('http://automation.whatismyip.com/n09230945.asp').read()
3
If you don’t want to rely on someone else, then just upload something like this PHP script:
JavaScript
1
2
1
<?php echo $_SERVER['REMOTE_ADDR']; ?>
2
and change the URL in the Python or if you prefer ASP:
JavaScript
1
5
1
<%
2
Dim UserIPAddress
3
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
4
%>
5
Note: I don’t know ASP, but I figured it might be useful to have here so I googled.