KidJames

I am trying to retrieve the WAN side IP address of my router within a windows form. I am using VS 2005, programming in VB.net, developing a windows application (not a web app).

I have googled this to death, and I have come up with nothing.

If anyone can give me some direction, it would be very much appreciated.

Thanks in advance ĘCJames



Re: Visual Basic General Retrieve router WAN (outside) IP Address

ahmedilyas

you cant quite do this im afraid, if you are using private IP's distributed by a DHCP server. You would need to perhaps use a 3rd party webservice or website and extract information from there as there is no way of retrieving your IP if its "hidden" from clients (using a router for example) since the point of contact would be the router that gives you the IP Address for your computer.






Re: Visual Basic General Retrieve router WAN (outside) IP Address

JohnWein

You need a cooperative web site. The best known is whatismyip.com. They make it easy for you:

Code Snippet

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim WC As New System.Net.WebClient

TextBox1.Text = System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://whatismyip.com/automation/n09230945.asp")))

WC.Dispose()

End Sub

This requires internet access, but if your address is static you should have the address and if it is dynamic you need an internet connection to get an address.