Find IP Address

  • Thread starter Thread starter Souljaz
  • Start date Start date
IP Address of the local machine? If yes, this is one way:

Dim local As IPHostEntry = Dns.Resolve(Dns.GetHostName())
For ip As IPAddress In local
Console.WriteLine (ip)
Next

Hope this helps.

Hi, how to find IP address. Thanks
 
Hi there, where should I put these code,
Another thing I am looking global IP address

Any idea?
 
Hi,

Here an alternative
\\\Dim IPAdres As String = System.Net.Dns.Resolve _
(SystemInformation.ComputerName).AddressList(0).ToString
///

I hope this helps?

Cor
 
Import the System.Net namespace and this should work from any module/class.
You might want to index (like local(0)) the array returned from
Dns.Resolve() to access the specific address for your processing.

Can you give more info on what you mean by 'global ip address'?

Hi there, where should I put these code,
Another thing I am looking global IP address

Any idea?
 
Hi all,

Thanks Cor Ligthert for the code, its work. But that is
to find local IP address right. What I want to find is
the dynamic IP address that provided by the ISP. Thanks
 
Hi,

I have no dynamic IP adress provided by the ISP, however is that not the
same?

When you have more Ip adresses I would look at the code that Shiva provided.

Cor
 
It is not the same, The local IP address is Ip address
that is set by the windows or by the user. If you
connected to LAN you will have Local IP address that can
be set dynamic or static for the particular computer in
LAN. But the IP Address that provided by the ISP is the
global IP address or WAN IP address. It is normally set
by the ISP and everytime you reconnect again the IP
address will be change.

try to go to this sites
http://www.html-kit.com/e/browconninfo.cgi

The sites will show you the IP address that provided by
the ISP.

Most of the code that provided here is to find the local
IP address. WHat I want to find the the IP address that
is provided by the ISP.

Any idea guys?

Thanks
 
As I asked did you try the sample of Shiva.

You can see your IP adresses by the way by doing in the DOS prompt

IPConfig

I hope this helps?

Cor
 
Hi shiva,
I try to put your code in form_load

Dim local As IPHostEntry = Dns.Resolve(Dns.GetHostName())
For ip As IPAddress In local
Console.WriteLine (ip)
Next

But there is an error saying that:
'For' loop control variable cannot be of
type 'System.Net.IPAddress'.

Whats the problem?
 
Sorry, I missed .AddressList in the For statement:

Here is the working code:

Dim local As IPHostEntry = Dns.Resolve(Dns.GetHostName())
For Each ip As IPAddress In local.AddressList
Console.WriteLine (ip)
Next

Hi shiva,
I try to put your code in form_load

Dim local As IPHostEntry = Dns.Resolve(Dns.GetHostName())
For ip As IPAddress In local
Console.WriteLine (ip)
Next

But there is an error saying that:
'For' loop control variable cannot be of
type 'System.Net.IPAddress'.

Whats the problem?
 
They are the same thing... The IP you connect to the net is the one on the
machine.

If you have a gateway/router/proxy then you have to run your code on that
machine. You're machine has no idea what IP the other hardware is using.
 

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