Getting Local machine IP address

  • Thread starter Thread starter Chakravarti Mukesh
  • Start date Start date
C

Chakravarti Mukesh

Hi all,

I need to know the IP address of the machine where the application is
running. How can I get this?

Thanks
Chakravarti Mukesh
 
Chakravarti said:
Hi all,

I need to know the IP address of the machine where the application is
running. How can I get this?

Something like:

string hostname = Dns.GetHostName();

IPHostEntry h = Dns.Resolve(hostname);

Trace.WriteLine("IP addresses for " + hostname + ":");

foreach (IPAddress ip in h.AddressList) {
Trace.WriteLine(ip);
}

This lists all your local ip addresses (except of 127.0.0.1).

hth,
Max
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top