Bugs: Browse | Submit New | Admin

[#27679] Ubuntu 9.10 ip_addr returns only ips from one nic

Date:
2010-01-11 13:15
Priority:
3
Submitted By:
Murmansk Manny (murmansk)
Assigned To:
Daniel Berger (djberg96)
Category:
sys-host
State:
Closed
Summary:
Ubuntu 9.10 ip_addr returns only ips from one nic

Detailed description
Found a similar problem with the windows version of sys-host a year ago.

Sorry I can't provide a patch, I've read the code but have not enough skills.

Tested with ubuntu 9.10 spanish, ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux], rubygems 1.3.5, sys-host (0.6.1).

The ip is configured using DHCP. The system has two nics: wired eth0 (ip 10.139.108.123) and wireless eth1 (not
connected).

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'sys/host'
=> true
irb(main):003:0> Sys::Host.ip_addr
=> ["127.0.1.1"]

Ifconfig Output
> ifconfig
eth0      Link encap:Ethernet  direcciónHW 00:16:ec:bc:1b:b5  
          Direc. inet:10.139.108.123  Difus.:10.139.108.255  Másc:255.255.255.0

eth1      Link encap:Ethernet  direcciónHW 00:02:b3:ab:8b:0e  
...

lo        Link encap:Bucle local  
          Direc. inet:127.0.0.1  Másc:255.0.0.0

Add A Comment: Notepad

Please login


Followup

Message
Date: 2013-10-16 18:32
Sender: Daniel Berger

This is simply too difficult for me, and as of Ruby 2.1 there
is Socket.getifaddrs. Closing.
Date: 2012-04-04 03:12
Sender: Daniel Berger

One thing to do would be to wrap getifaddrs using ffi, though
it doesn't work on all platforms.
Date: 2010-08-14 16:59
Sender: Murmansk Manny

Ipsocket.getaddress returns the same local address:
-------------------------------------
irb(main):009:0> Socket.gethostname
=> "simun"
irb(main):010:0> IPSocket.getaddress(Socket.gethostname)
=> "127.0.1.1"
-------------------------------------
Date: 2010-01-18 08:51
Sender: Daniel Berger

Just out of curiousity, what does
IPSocket.getaddress(Socket.gethostname) return?

Regards,

Dan

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
close_date2013-10-16 18:322013-10-16 18:32djberg96
resolution_idAccepted2013-10-16 18:32djberg96
status_idOpen2013-10-16 18:32djberg96
artifact_group_idNone2012-04-04 03:12djberg96
resolution_idNone2012-04-04 03:12djberg96