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?
This is the code to get external IP-adress:
Public Class Form1
Private Function GetInternetIPAddress() As String
Dim _ObjReq As HttpWebRequest = WebRequest.Create("http://automation.whatismyip.com/n09230945.asp")
Dim _ObjRes As HttpWebResponse = _ObjReq.GetResponse()
Dim _ObjStream As Stream = _ObjRes.GetResponseStream()
Dim _ObjSR As StreamReader = New StreamReader(_ObjStream)
Catch ex As Exception
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = GetInternetIPAddress()
Download Source code :
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 ]
It shows your LAN IP address.