skip at pobox.com
Sat Jan 26 23:28:33 CET 2002
Max> how can i get the internet ip address of my connected pc?
If you are directly connected to the net (no firewall for example), you can
If, on the other hand, you are living behind a firewall and want to know
what IP address the rest of the world thinks you are coming from, I think
you have to coax another site into telling you. This works for me:
import smtplib, re, socket, os, sys
s = smtplib.SMTP("mail.mojam.com")
code, msg = s.helo()
mat = re.search("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)", msg)
if mat is not None:
print "IP address unknown"
I'd be interested in seeing how others have solved this problem.
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
More information about the Python-list