Hi all,
I'd like to get, in a portable way, a list of all
network adapters on a local machine running some
python code.
socket.gethostname() does not seem enough, as it
only returns one name ; I'd like to get all
available IPs.
I could process ipconfig or ifconfig outputs, but
this is OS-dependant and not very future-proof...
Best regards,
Olivier Parisy. 7 4109
> I could process ipconfig or ifconfig outputs, but this is OS-dependant and not very future-proof...
This has been discussed quite a few times on this NG, search google groups.
However IMHO there is no general system built-in way (AFAIK not even posix)
for doing this, you'll end up parsing tool output anyway...
--
Regards,
Diez B. Roggisch
Diez B. Roggisch wrote: This has been discussed quite a few times on this NG, search google groups. However IMHO there is no general system built-in way (AFAIK not even posix) for doing this, you'll end up parsing tool output anyway...
I should have done this first, my mistake...
But actually, a previously posted message suggests a portable way to get
the platform IPs. Citing John Abel :
socket.gethostbyaddr( socket.gethostname() ) will return all the details that you need to know. For example, the output of that command on my machine is :
('hallows', [], ['101.101.101.102', '10.253.1.118'])
Are there some pitfalls I'm not aware of ?
Thanks,
Olivier Parisy.
Olivier Parisy wrote:
[snip] But actually, a previously posted message suggests a portable way to get the platform IPs. Citing John Abel :
> socket.gethostbyaddr( socket.gethostname() ) will return all the > details that you need to know. For example, the output of that > command on my machine is : > > ('hallows', [], ['101.101.101.102', '10.253.1.118'])
Are there some pitfalls I'm not aware of ?
Doesn't seem to work right on Windows, for me at least: socket.gethostbyaddr(socket.gethostname())
('<my machine name>', [], ['169.254.0.100'])
It returned the least useful of my 3 IP addresses - my loopback adapter
- but didn't return my LAN and wireless IPs.
-Dave
Dave Brueck <da**@pythonapocrypha.com> writes: Olivier Parisy wrote: [snip] But actually, a previously posted message suggests a portable way to get the platform IPs. Citing John Abel : > socket.gethostbyaddr( socket.gethostname() ) will return all the > details that you need to know. For example, the output of that > command on my machine is : > > ('hallows', [], ['101.101.101.102', '10.253.1.118']) Are there some pitfalls I'm not aware of ?
Doesn't seem to work right on Windows, for me at least:
>>> socket.gethostbyaddr(socket.gethostname())
('<my machine name>', [], ['169.254.0.100'])
It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
If anyone really needs it, I can post code for windows using ctypes to
collect ip-addresses and netmasks together with the name and description
of all network adapters.
Thomas
> > It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
Interesting! I have Python installed on 10 W2K servers and I'm using
the same construct to get addresses. Works fine for me.
Elbert Lev wrote: It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs.
Interesting! I have Python installed on 10 W2K servers and I'm using the same construct to get addresses. Works fine for me.
WinXP Pro here - I wonder if that's the difference.
-Dave
Dave Brueck wrote: Elbert Lev wrote:
It returned the least useful of my 3 IP addresses - my loopback adapter - but didn't return my LAN and wireless IPs. Interesting! I have Python installed on 10 W2K servers and I'm using the same construct to get addresses. Works fine for me.
WinXP Pro here - I wonder if that's the difference.
Interestingly, I have the same problem with XP Pro.
But socket.gethostbyname_ex seems to do the trick for me !
Regards,
Olivier. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gordon Knote |
last post by:
Hi
how can I enumerate (and get information about) all installed network adapters on a local machine (in .net)
Thanks a lo
Gordon
|
by: LK |
last post by:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip
addresses, dns, etc.) with csharp.
I need the type of information that would come up when typing
ipconfig /all
...
|
by: Michael C |
last post by:
Hi all,
After a lot of research, I've come to some realizations about enumerating
Named Instances of MSDE. NetServerEnum() Win32 API function doesn't work,
SQL-DMO doesn't work, no standard...
|
by: Maniaque |
last post by:
Does anybody knows, how can I address multiply network adapters on one
computer?
I've looked up through classes reference and found nothing.
Thanks in advance.
--
.... blood, sugar, sex,...
|
by: Glenn Leifheit |
last post by:
Does anyone have any sample code on enumerating network shares with vb.net.
I here you need to use wither an API or WMI, or are there other
recomendations.
Thanks
Glenn
|
by: Joe User |
last post by:
Hi - I found the class below on another website (www.devx.com)
and can't seem to figure out how to make a call to this class to
retrieve the machines and put them in a listbox.
I am definitely a...
|
by: Phil Galey |
last post by:
Is there any way of enumerating all printers, including network printers in VB.NET?
printing.PrinterSettings.InstalledPrinters only enumerates printers attached to the local workstation. ...
|
by: amir |
last post by:
Hello All,
I am currently looking for writing an application that will act like
a
network bridge. Meaning, I have 2 network adapters and i want all
thing
from 1 adapter will pass directly to the...
|
by: =?Utf-8?B?TWFydGlu?= |
last post by:
In Device Manager under Network Adapters, nearly all (about 20) items have a
yellow warning symbol. The first item, Microsoft 6to4 Adapter says driver is
up-to-date BUT says "This device is not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |