Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 02-26-2007, 12:53 AM   #1
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, 01:51 AM   #2
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 377Reputation: 377Reputation: 377Reputation: 377
have you considered doing an strace to see where ifconfig gets the info??
strace ifconfig
Old 02-26-2007, 02:55 AM   #3
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:

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


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 09:55 AM
Odd IP address in ifconfig (Etch) farpoint Debian 8 12-11-2006 11:10 AM
ifconfig reports wrong mac address and wireless doesn't work blackdragonblood Linux - Wireless Networking 7 04-15-2006 12:08 PM
second ethernet interface will not configure using ifconfig akay Linux - Hardware 0 12-14-2004 06:45 PM
extracting IP address from ifconfig nowonmai Programming 2 11-24-2003 03:28 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:39 PM.

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