How to get IP address

Gerhard Häring gerhard.haering at opus-gmbh.net
Mon Mar 3 15:04:57 CET 2003


Nagy László Zsolt <nagylzs at freemail.hu> wrote:
> It seems to me that there is no way to get all IP addresses of the machine
> where your Python program is running. The standard library does not provide a
> function to do this. [...]
> Any comments from Python experts? Did I missed something?

Sorry, I haven't read this thread. What I'd try to do is parse the routing
information from the operating system. How to get this information is
platform dependent, on Linux, you can use "route -n", on FreeBSD,
"netstat -rn" and on Windows "route print".

My Windows here says:

[...]
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.0.5   192.168.0.195       1
[...]

-- Gerhard




More information about the Python-list mailing list