Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: ifconfig in python

Reply
Thread Tools

Re: ifconfig in python

 
 
James Mills
Guest
Posts: n/a
 
      01-20-2009
On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres <(E-Mail Removed)> wrote:
> Is ther an easy way to get the resolved ip address of the machine a script
> is running on? socket.gethostbyname(socket.gethostname) has only returned
> the ip address of my loop back interface ... not very usefull.


That's because your /etc/hosts resolves
your hostname to 127.0.0.1

And no I know of no "easy" way cross
platform way. Perhaps parsing the output
of ifconfig itself ?

cheers
James
 
Reply With Quote
 
 
 
 
Mark Wooding
Guest
Posts: n/a
 
      01-20-2009
"James Mills" <(E-Mail Removed)> writes:

> On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres <(E-Mail Removed)> wrote:
>> Is ther an easy way to get the resolved ip address of the machine a
>> script is running on? socket.gethostbyname(socket.gethostname) has
>> only returned the ip address of my loop back interface ... not very
>> usefull.

>
> That's because your /etc/hosts resolves your hostname to 127.0.0.1


This just illustrates the real problem with the OP's question. The idea
of `/the/ ... ip address of the machine' is simply ill-formed.

An Internet host has at least two IP addresses -- one of them is
127.0.0.1 -- and may have many more. The laptop I'm typing on right now
has three; the server next door has four. Network interfaces may have
multiple addresses associated with them (and hosts using the weak
end-system model consider the addresses as referring to the host in
general rather than a specific interface anyway), and several interfaces
might have the same address.

Sorry. Life's more complicated than you'd like it to be.

-- [mdw]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: ifconfig in python bruce Python 1 01-20-2009 07:31 PM
Re: ifconfig in python Дамјан Георгиевски Python 3 01-20-2009 05:41 PM
RE: ifconfig in python bruce Python 0 01-20-2009 03:31 PM
portable Python ifconfig Bart Van Loon Python 6 03-04-2007 09:14 AM
java ifconfig voger Java 19 11-10-2005 10:10 PM



Advertisments