Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
find External IP Address in VB.NET
Old 12-05-2008, 12:29 PM find External IP Address in VB.NET
Experienced Talker

Posts: 35
Name: remya
Trades: 0
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...
Code:
 Dim IPHost As IPHostEntry = Dns.GetHostByName(Dns.GetHostName())
 MessageBox.Show("My IP address is " & IPHost.AddressList(0).ToString())
and i tried this code too...
Code:
Imports System
Imports System.Text
Imports System.Text.RegularExpressions
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)
            MessageBox.Show(externalIp.ToString)
        End If
End Sub
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...
Quote:
? r
{System.Text.RegularExpressions.Regex}
Options: None
RightToLeft: False
? r.Match(requestHtml)
{System.Text.RegularExpressions.Match}
Captures: {System.Text.RegularExpressions.CaptureCollection}
Empty: {System.Text.RegularExpressions.Match}
Groups: {System.Text.RegularExpressions.GroupCollection}
Index: 0
Length: 0
Success: False
Value: ""
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.
remya1000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-05-2008, 01:25 PM Re: find External IP Address in VB.NET
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Try ping from the command line, and from your code - it's easier and more light weight.

http://msdn.microsoft.com/en-us/libr...ng(VS.80).aspx
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 01:34 PM Re: find External IP Address in VB.NET
Experienced Talker

Posts: 35
Name: remya
Trades: 0
Thanks Learning Newbie for your help....

I tried this code and it's working....
Code:
Dim req As HttpWebRequest = WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
        Dim res As HttpWebResponse = req.GetResponse()
        Dim Stream As Stream = res.GetResponseStream()
        Dim sr As StreamReader = New StreamReader(Stream)
        messagebox.show(sr.ReadToEnd())
remya1000 is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 02:37 PM Re: find External IP Address in VB.NET
$100 - $999 Monthly

Posts: 30
Trades: 0
I always thought the dns object is slow...
Can you try Request.ServerVariables["REMOTE_HOST"] ?
dealsguy is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 02:59 PM Re: find External IP Address in VB.NET
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by remya1000 View Post
Thanks Learning Newbie for your help....

I tried this code and it's working....
Code:
Dim req As HttpWebRequest = WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
        Dim res As HttpWebResponse = req.GetResponse()
        Dim Stream As Stream = res.GetResponseStream()
        Dim sr As StreamReader = New StreamReader(Stream)
        messagebox.show(sr.ReadToEnd())
That URL works from FireFox on my machine - does it work in your browser? They might have anti scraping code in place.

Try new WebClient().DownloadString(url);
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 07-23-2009, 07:56 AM Re: find External IP Address in VB.NET
Junior Talker

Posts: 1
Trades: 0
you can get the ip address from ip details.com or from the following steps
  1. Click on Start in the bottom left hand corner of your screen.
  2. Click on Run. An input box will appear with a flashing cursor.
  3. Type "cmd" or "Command" in the Run box.
    run cmd command

  4. Click on OK or press the Enter key on your keyboard.Or click on start. Go to programs.Go to Accessories and click on Comand Prompt.
  5. An MS DOS Window will open (see image). You are now ready to send a command to your computer.

    cmd command

  6. Type "netstat -n" including the space.
  7. Press Enter netstat command


  8. You will see a list of all your active connections and IP numbers.
  9. You will see four fields with four columns.
  10. The Local Address field identifies your IP number. The Foreign Address field shows the IP numbers of the sites or people to whom you are connected. In the image, I am talking to two friends on Messenger, so two IP addresses are shown in the Foreign Address field.
  11. You can also see what programs are being used to connect to those IP addresses by typing "netstat -nab". That way, if you are connected to more than one foreign IP address, you can more easily pick out the address you are interested in.
  12. Also another way you can do it is Start>Run>Cmd>Ipconfig This should show you: your masked IP and IP.
  13. An easy alternative way to determine your IP is to use an online IP checker like Get My IP Address
radha65 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to find External IP Address in VB.NET
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36521 seconds with 12 queries