[Mono-list] How to determine local IP address with mono on linux?

Colin JN Breame colin at breame.net
Fri Mar 24 07:08:23 EST 2006


You can get the address using the SIOCGIFADDR ioctl.  You'd probably have to 
do this in C.  Your best bet might be to parse the output from ifconfig.

 -- Colin

On Thursday 23 March 2006 17:06, Stephan Eberle wrote:
> Hi El,
>
> That's a good start. Do you know of any possibility to point out the device
> (eth0, eth1, wlan0, ...) behind each address?
>
> Thank's,
> Stevie
>
> On Thursday 23 March 2006 18:03, Elliott Draper wrote:
> > Hi there,
> >
> > Add a reference to System.Net to the top of your code file ("using
> > System.Net; "), and then try this:
> >
> > foreach(IPAddress address in
> > Dns.GetHostByName(Environment.MachineName).AddressList) {
> > Console.WriteLine(address.ToString());
> > }
> >
> > That simply prints out each IP address for your local machine to the
> > console, however you can do whatever you need to do within that
> > enumeration.
> >
> > Hope that helps,
> > -= El =-
> >
> > On Thu, 23 Mar 2006 17:48:34 +0100, Stephan Eberle <hawke at deltacity.org>
>
> wrote:
> > > Hi!
> > >
> > > How can I enumerate my machines IP addresses with mono on a linux box?
> > >
> > > Any info desperately needed! :)
> > >
> > > Thank's in advance,
> > > Stevie
> > > _______________________________________________
> > > Mono-list maillist  -  Mono-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-list
> >
> > _______________________________________________
> > Mono-list maillist  -  Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list


More information about the Mono-list mailing list