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

Elliott Draper el at eldiablo.co.uk
Thu Mar 23 12:03:33 EST 2006


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



More information about the Mono-list mailing list