Finding out your local IP in VB .net under IIS 7

Posted by on May 9, 2013 in Programming, VB .Net | 0 comments

If you’re looking for your IP address of your website chances are you know if, but in case you don’t, there are 2 ways to find it. There are also 2 different IP addresses you might be looking for. There’s a local IP address, then the IP address that the outside world sees and can access your web server on.

Here’s a VB .net code section to find your internal IP address, IE, your local IP address of the website on the network.

Dim ip() As Net.IPAddress = System.Net.Dns.GetHostAddresses(“”)

If ip.Count > 0 Then
For Each ipadd As Net.IPAddress In ip
Me.testdiv.InnerHtml = ipadd.ToString
Next
End If

Here’s a code section to see your outward facing IP address. Notice that you need to import the few things at the top of the code. This simply hits IPchicken.com and displays the results.

Imports System.IO
Imports System.Net

Dim reader As StreamReader
Dim request As WebRequest
Dim response As WebResponse
Dim data As String = “”

Try
request = WebRequest.Create(“http://www.ipchicken.com”)
request.Timeout = 30000
response = request.GetResponse()
reader = New StreamReader(response.GetResponseStream())
data = reader.ReadToEnd()
Catch ex As Exception
‘MsgBox(ex.Message)
End Try

Me.testdiv.InnerHtml = data

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>