ipaddr -> device

This is a discussion on ipaddr -> device within the Linux Networking forums, part of the Linux Forums category; On RedHat 9, programming in C++, on a machine that has several ethernet cards, I need to determine the device (...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-20-2004
Mike - EMAIL IGNORED
 
Posts: n/a
Default ipaddr -> device

On RedHat 9, programming in C++, on a machine that
has several ethernet cards, I need to determine the
device (eth0, eth1, etc.) from the ip address
(192.168.1.10, etc.). Is there a function that
will do this?

Thanks in advance for your help.

Mike.
Reply With Quote
  #2 (permalink)  
Old 05-21-2004
Mike - EMAIL IGNORED
 
Posts: n/a
Default Re: ipaddr -> device

Robert Spielmann wrote:
>
> On Wed, 19 May 2004 22:04:42 -0400
> Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote:
>
> > On RedHat 9, programming in C++, on a machine that
> > has several ethernet cards, I need to determine the
> > device (eth0, eth1, etc.) from the ip address
> > (192.168.1.10, etc.). Is there a function that
> > will do this?

>
> read /etc/network/interfaces? (if the IP addresses are static)

[...]

I do not have this file on my RH9. My ip addresses are static.

Mike.
Reply With Quote
  #3 (permalink)  
Old 05-21-2004
Floyd L. Davidson
 
Posts: n/a
Default Re: ipaddr -> device

Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote:
>Robert Spielmann wrote:
>>
>> On Wed, 19 May 2004 22:04:42 -0400
>> Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote:
>>
>> > On RedHat 9, programming in C++, on a machine that
>> > has several ethernet cards, I need to determine the
>> > device (eth0, eth1, etc.) from the ip address
>> > (192.168.1.10, etc.). Is there a function that
>> > will do this?

>>
>> read /etc/network/interfaces? (if the IP addresses are static)

>[...]
>
>I do not have this file on my RH9. My ip addresses are static.


He probably meant /proc/net/dev, but that is not really
satisfactory because while it does list interfaces, it does not
list the ip addresses.

There have been many articles posted to Usenet showing the correct
use of SIOGCIFCONF using C, which should suffice as an example of
where to start with C++. (I've posted several myself.)

Go to http://groups.google.com/advanced_group_search and do a
search the word SIOGCIFCONF restricted to comp.os.linux.* only,
and you'll come up with several articles.

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@barrow.com
Reply With Quote
  #4 (permalink)  
Old 05-21-2004
Cameron Kerr
 
Posts: n/a
Default Re: ipaddr -> device

Robert Spielmann <des64NOSPAM@gmx.de> wrote:
> On Wed, 19 May 2004 22:04:42 -0400
> Mike - EMAIL IGNORED <m_d_berger_1900@yahoo.com> wrote:


>> I need to determine the device (eth0, eth1, etc.) from the ip address
>> (192.168.1.10, etc.). Is there a function that will do this?

>
> read /etc/network/interfaces? (if the IP addresses are static)


Certainly not, that's Debian specific, and devices can be configured in
various other ways (esp dhcp).

--
Cameron Kerr
cameron.kerr@paradise.net.nz : http://nzgeeks.org/cameron/
Empowered by Perl!
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0