Getting local IP address...
pehr anderson
pehr at pehr.net
Thu Jul 20 01:20:51 EDT 2000
I would be *very* interested in a module that made it easy to access
low-level interface information.
There are a few goodies python excludes, for better or worse, in
the name of cross-platform portability:
1. localhost IP addresses,
2. MAC addresses for ethernet interfaces,
3. listing available PPP addresses with an interface to connect /
disconnect.
4. raw_sockets support. I haven't delved deeply enough to know why this
is excludeded but for embedded development it is *really* handy.
5. Built-in library for cross-platform serial device interfaces.
This is one we are starting to put together at work.
We currently do a lot of development that looks as follows:
python --Ethernet--> lantronix --RS232--> embddded device
Imagine a serial port interface for python that could talk to
linux serial ports, windows serial ports, and ports accross a
network using a terminal server!
-pehr
David Arnold wrote:
>
> -->"Stephen" == Stephen Hansen <stephen%cerebralmaelstrom.com.bbs at openbazaar.net> writes:
>
> Stephen> Um, jeez. I'm rather surprised by these responses -- I
> Stephen> assumed it was some simple little function somewhere I was
> Stephen> missing.
>
> sadly not. in the simple case, gethostbyname(gethostname()) will do
> what you want, but for machines with multiple interfaces it's not
> guaranteed to get you a useful IP address.
>
> this is particularly the case for a machine with a dialup PPP link,
> and a local ethernet card using (just to exhibit some more complexity)
> a NATed private address range. in this case, it's likely that the
> reverse lookup on the hostname would return the NATed address, which
> is useless to external hosts.
>
> the third approach has load implications, but is at least portable and
> reliable ...
>
> i've been looking at the available facilities (under Unix) for finding
> interfaces and addresses, and it's reasonably arcane, and has a lot of
> portability warning, but it's tempting to write a small module to
> expose the functionality.
>
> one complication i found today is that h2py (needed to get the
> constants for use with ioctl()) doesn't support multi-parameter
> macros, and consequently IOCTL on Solaris doesn't work ...
>
> anyone have plans to extend h2py for 1.6/2.0 to support multi-arg
> macro translations?
>
> anyone interested in a general interface info module?
>
> d
More information about the Python-list
mailing list