How to find IP address with VB.NET

This program explains How to find IP address with VB.NET. This code is an easy method to get your IP address. I did a search and didn’t find something similar. I hope this is the simple VB.Net function to get external IP-adress.  The source code is attached in this article.

How to find IP address with VB.NET

How to find IP address with VB.NET?

This is the code to get external IP-adress:

Download Source code :

knowledge base:

What kind of IP address does whatismyip.com provide? How can I get it using VB.Net code?
Ans : whatismyip.com provides your WAN IP. whatismyip.com kind of website is useful when you’re behind a router. www.whatismyip.com reads the source IP Address from the IPv4 protocol header your computer, router, or proxy generates when it prepares an HTTP request to send to whatismyip.com while requesting the content of a webpage and it prints this address back to the page before delivering it to you.

How to find LAN IP?
Answer: Easier way to find LAN IP is to run this command in command prompt :

Go to start -> RUN -> Type

[ start | run | cmd.exe ]

ipconfig /all

It shows your LAN IP address.

3 Responses to How to find IP address with VB.NET

  1. frederm says:

    the problem here is that whatismyip will limit how many times you can make this request (300 seconds per attempt). If you have access to your own website then make a .asp page.
    this page simply has:

    that page should return the wanIP. then you can access this page when ever you want.
    in any .net application you can then use code such as yours.
    Private Function GetMyIP() As String
    Using wc As New Net.WebClient
    Dim b() As Byte =wc.DownloadData(“http://yourwebsite/whatismyip.aspx”)
    Return getstring(b) ‘function to create string from byte array. typical method
    End Using
    End Function
    Function getstring(b() As Byte) As String
    Return System.Text.ASCIIEncoding.ASCII.GetString(b)
    End Function

  2. frederm says:

    it did not show the code to do the aspx page for some reason:

    if the above does not show then use the normal “” end.
    that is all that needs to be on the page except for the normal aspx header.

Leave a Reply