LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 02-26-2007, 01:53 AM   #1
nachosmith
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Rep: Reputation: 0
Getting IP address for a network interface through the filesystem, not ifconfig


I'm using an embedded system that is running a cut-down version of linux. We're running a Java app on top of it.

I need to find the IP address for a network interface, so I can use it in my program. The only problem is I can't make a call to ifconfig to read the ip address information because on this platform, running external processes from Java is broken, unfortunately (and there's no fix in sight either).

So I figure there must be a way to get this information from the filesystem, somewhere. Like from /proc or /sys or something. I've had a pretty good look but couldn't see anything.

Can anyone tell me how I can get the IP address for a network interface without having to run a command (like ifconfig)???

Thanks in advance
 
Old 02-26-2007, 02:51 AM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
have you considered doing an strace to see where ifconfig gets the info??
Code:
strace ifconfig
 
Old 02-26-2007, 03:55 AM   #3
nachosmith
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Original Poster
Rep: Reputation: 0
system call: ioctl

Thanks mate. That was a very helpful little piece of information. I found out it is done through a system call:

Code:
ioctl(4, SIOCGIFCONF, {64, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, {"eth0", {AF_INET, inet_addr("192.168.1.5")}}}}) = 0
Thanks for your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Port/Address forwarding with iptables with one network interface. Nextrastus Linux - Networking 5 09-18-2013 10:55 AM
Odd IP address 169.254.187.86 in ifconfig (Etch) farpoint Debian 8 12-11-2006 12:10 PM
ifconfig reports wrong mac address and wireless doesn't work blackdragonblood Linux - Wireless Networking 7 04-15-2006 01:08 PM
second ethernet interface will not configure using ifconfig akay Linux - Hardware 0 12-14-2004 07:45 PM
extracting IP address from ifconfig nowonmai Programming 2 11-24-2003 04:28 AM


All times are GMT -5. The time now is 09:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration