How to get the ip addresses of a nic
Donn Cave
donn at drizzle.com
Thu Apr 22 02:43:08 EDT 2004
Quoth Rob Nikander <rnikaREMOVEnder at adelphia.net>:
| Justin Dubs wrote:
| >>>>socket.gethostbyname(socket.gethostname())
|>
|> '192.168.0.18'
|
|
| That always gives me this:
|
| >>> import socket
| >>> socket.gethostbyname(socket.gethostname())
| '127.0.0.1'
That isn't your address?
Try something like this -
t = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
t.connect(('my.dns.server', 53))
print t.getsockname()
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list