Hi,
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).
Thanks!
Joe
Hi,
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).
Thanks!
Joe
Hi,
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).
on linux systems its in /sys/class/net/eth0/address
If some day someone provides bindings to the hardware abstraction layer
(libhal) you could query it from there ![]()
Cheers
detlef
Am Dienstag, den 18.10.2005, 03:01 +0900 schrieb Joe Van Dyk:
Thanks!
Joe
Try this:
ifconfig en0 inet | grep inet | awk '{print $2}'
Where "en0" is the subject of query.
Cheers,
Gábor
"értelmező kéziszótár: rekurzió --> lásd: rekurzió"
On 2005.10.17., at 20:01, Joe Van Dyk wrote:
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).
Joe Van Dyk <joevandyk@gmail.com> writes:
Hi,
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).Thanks!
Joe
Parsing ifconfig is the only method that works on the largest number
of OSes.
Other than that, you'd have to use OS-dependent feature like what
Detlef Reichl has shown.
YS.
Well, you don't need to run it under sudo..... ![]()
On 17/10/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
Hi,
Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
a way to get the current IP address of a NIC? (say, eth0).
--
Rasputin :: Jack of All Trades - Master of Nuns
http://number9.hellooperator.net/
> Hi,
>
> Other than parsing the output of `sudo /sbin/ifconfig`, anyone know of
> a way to get the current IP address of a NIC? (say, eth0).
>on linux systems its in /sys/class/net/eth0/address
That looks like the Mac address, not the IP address.
If some day someone provides bindings to the hardware abstraction layer
(libhal) you could query it from there
I actually have some code wrapping rtnetlink socket, which can get you
lots of routing information (man 7 rtnetlink). Although I use this code
to query the bandwidth manager on live machines, the code has a memory
leak, is alpha quality and fairly incomplete. I think rtnetlink is
pretty much Linux specific too.
If there is enough interest to pump up my motivation, I'll try to finish
it.
Guillaume.
On Tue, 2005-10-18 at 03:24 +0900, Detlef Reichl wrote:
Am Dienstag, den 18.10.2005, 03:01 +0900 schrieb Joe Van Dyk:
Cheers
detlef> Thanks!
> Joe
>