i'm using VB
.NET 2003 Application program. i need to get External IP Address (internet). i searched internet and found come codes and tried that...
i tried this code... but it returned my internal IP Address...
Dim IPHost As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
MessageBox.Show("My IP address is " & IPHost.AddressList(0).ToString())
and i tried this code too...
Public Sub GetExternalIP()
Dim whatIsMyIp As String = "http://whatismyip.com"
Dim getIpRegex As String = "(?<=<TITLE>.*)\d*\.\d*\.\d*\.\d*(?=</TITLE>)"
Dim wc As WebClient = New WebClient
Dim utf8 As UTF8Encoding = New UTF8Encoding
Dim requestHtml As String = ""
Dim externalIp As IPAddress = Nothing
requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp))
Dim r As Regex = New Regex(getIpRegex)
Dim m As Match = r.Match(requestHtml)
If (m.Success) Then
externalIp = IPAddress.Parse(m.Value)
but its always returns (m.fail) instead of (m.Success). so i'm not able to get External Ip address.
using command window - Immediate, i get values for "r" and "m". and m.success = false...
i don't have fire wall setup in my machine. and i have internet access too...
anything wrong in that code.. or anything i'm missing... if anyone have any idea how to find out the External Ip Address, please help me. if you can provide an example, then it will be a great help for me.
Thanks in advance.