How to retrieve IP address ???

  • Thread starter Thread starter serge calderara
  • Start date Start date
S

serge calderara

Dear all,

I have a tool which is able to receive any kind of data
from a remote system.
For that I need to get the ipadress of the remote system.

If the system is not connected to a DHCP server no
problem , I set in my configuration the ip adress.

Then if my remote system is connected to a DHCP server,
how can I get retriev the given IP adress ?

thanks for your help
regards
serge
 
Hi Serge,

Do you have the machine name or DNS name of the machine? If so you can use
System.Net.Dns.GetHostByName("theName") to get the IP address(es) for the
machine.

Such as:
IPHostEntry hostInfo = Dns.GetHostByName("jimblizz01");
Console.WriteLine("host name: " + hostInfo.HostName);
IPAddress[] address = hostInfo.AddressList;
Console.WriteLine("\nIP address list : ");
for(int index=0; index < address.Length; index++)
{
Console.WriteLine(address[index]);
}

Console.ReadLine();

Hope this helps,
- bliz

Jim Blizzard, MCSD .NET | http://www.snowstormlife.com/blog
Community Developer Evangelist | http://www.microsoft.com/communities

This posting is provided AS IS, without warranty and confers no rights.
 
Thanks for your answer....
Yes the only thing I might know is the name of the PC.
But the way my customer will handle name resolution is not
under my control.

Can I used what you suggest?

regards
serge
-----Original Message-----
Hi Serge,

Do you have the machine name or DNS name of the machine? If so you can use
System.Net.Dns.GetHostByName("theName") to get the IP address(es) for the
machine.

Such as:
IPHostEntry hostInfo = Dns.GetHostByName("jimblizz01");
Console.WriteLine("host name: " + hostInfo.HostName);
IPAddress[] address = hostInfo.AddressList;
Console.WriteLine("\nIP address list : ");
for(int index=0; index < address.Length; index++)
{
Console.WriteLine(address[index]);
}

Console.ReadLine();

Hope this helps,
- bliz

Jim Blizzard, MCSD .NET | http://www.snowstormlife.com/blog
Community Developer Evangelist | http://www.microsoft.com/communities

This posting is provided AS IS, without warranty and confers no rights.


Dear all,

I have a tool which is able to receive any kind of data
from a remote system.
For that I need to get the ipadress of the remote system.

If the system is not connected to a DHCP server no
problem , I set in my configuration the ip adress.

Then if my remote system is connected to a DHCP server,
how can I get retriev the given IP adress ?

thanks for your help
regards
serge


.
 
I don't quite understand the situation when you say name resolution isn't
under your control....

If you have the machine name, you should be able to get the IP address.

Can you clarify?

Thanks!

--
Jim Blizzard, MCSD .NET
Community Developer Evangelist | www.microsoft.com/communities
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).


--------------------
Content-Class: urn:content-classes:message
From: "serge calderara" <[email protected]>
Sender: "serge calderara" <[email protected]>
References: <[email protected]>
Subject: Re: How to retrieve IP address ???
Date: Wed, 22 Oct 2003 23:42:53 -0700
Thanks for your answer....
Yes the only thing I might know is the name of the PC.
But the way my customer will handle name resolution is not
under my control.

Can I used what you suggest?

regards
serge
-----Original Message-----
Hi Serge,

Do you have the machine name or DNS name of the machine? If so you can use
System.Net.Dns.GetHostByName("theName") to get the IP address(es) for the
machine.

Such as:
IPHostEntry hostInfo = Dns.GetHostByName("jimblizz01");
Console.WriteLine("host name: " + hostInfo.HostName);
IPAddress[] address = hostInfo.AddressList;
Console.WriteLine("\nIP address list : ");
for(int index=0; index < address.Length; index++)
{
Console.WriteLine(address[index]);
}

Console.ReadLine();

Hope this helps,
- bliz

Jim Blizzard, MCSD .NET | http://www.snowstormlife.com/blog
Community Developer Evangelist | http://www.microsoft.com/communities

This posting is provided AS IS, without warranty and confers no rights.


Dear all,

I have a tool which is able to receive any kind of data
from a remote system.
For that I need to get the ipadress of the remote system.

If the system is not connected to a DHCP server no
problem , I set in my configuration the ip adress.

Then if my remote system is connected to a DHCP server,
how can I get retriev the given IP adress ?

thanks for your help
regards
serge


.
 
Back
Top