- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Model: R7000|AC1900 Smart WIFI Router: How to read public IP from a Windows script?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Model: R7000|AC1900 Smart WIFI Router: How to read public IP from a Windows script?
How can I read the routers public IP in a Windows script so I can implement my own DynDNS.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Model: R7000|AC1900 Smart WIFI Router: How to read public IP from a Windows script?
> How can I read the routers public IP in a Windows script so I can
> implement my own DynDNS.
Leaving aside the question of whether you know enough to do that if
you're asking this, ...
You might use a program like Wget to fetch a web page which contains
the desired datum, and scrape it from what comes back. That might be
one of the many "What's my IP address" web sites out there, or something
direct from the router.
On an R7000 (firmware: V1.0.11.116_10.2.100) you could do it using
one of the ADVANCED > ADVANCED Home frames from the router. For
example, using some UNIXy text processing to begin the scraping:
$ wget --user=admin --password=password2 -O r7_adv_home.out \ http://192.168.1.1/ADVANCED_home2.htm $ grep -A 2 '>IP Address <' r7_adv_home.out | tail -1 <td class="basic-text-content" >0.0.0.0
(The white space is not my fault. The WAN port on this router is
unconnected, hence the "0.0.0.0".)
In a Windows CMD or PowerShell, you're on your own.
As usual, many things are possible. There may even be some good way
to do it.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Model: R7000|AC1900 Smart WIFI Router: How to read public IP from a Windows script?
Many thanks for your comments.
Although not exactly what I was looking for, your comments got me thinking and I was able to solve my issue. Because my WAN address is dynamic, it is subject to change without warning; especially if power is out for over one hour. When this happens and I am not at my home, I cannot access my computers via RDP because I no longer know the WAN IP address! To solve this issue, I created a VB.net application that periodically obtains the WAN IP address and reports (via email) if it has changed. I installed this applicaton as a Windows Service so that the applicaton would always start when one of my home computers booted (after a power loss).
To try to cover all possibilities, I attempt to get the WAN IP address using three different sources:
2. https://www.iplocation.net/find-ip-address
3.http://192.168.1.1/RST_status.htm (my RBR Orbi Router - RBR50 - Version 2.5.2.4)
I had figured out how to extract the WAN IP address from items 1 and 2 above. Item 3 was the reason for my request in this forum!
The code segment implemented for Item 3 is listed below:
Private lg_WANIPAddress_MostRecent As String = ""
Private lg_LinkUsedToRetrieveWANIP = ""
Private Function GetWANAddressSuccessful_Try3(ByRef WANIPAddress As String) As Boolean
Const const_WebIPSourceToRetrieveWANAddress = "http://192.168.1.1/RST_status.htm"
GetWANAddressSuccessful_Try3 = False
WANIPAddress = ""
Dim RequestFromWeb As HttpWebRequest
Dim ResponseFromWeb As HttpWebResponse
Dim Webstream As Stream
Dim StreamReaderFromWeb As StreamReader
Try
RequestFromWeb = WebRequest.Create(const_WebIPSourceToRetrieveWANAddress)
RequestFromWeb.Credentials = New System.Net.NetworkCredential("username", "password")
ResponseFromWeb = RequestFromWeb.GetResponse()
Webstream = ResponseFromWeb.GetResponseStream()
StreamReaderFromWeb = New StreamReader(Webstream)
WANIPAddress = StreamReaderFromWeb.ReadToEnd()
Dim TestString = ""
Dim MyIPAddressPosition_Start As Integer
Dim MyIPAddressPosition_End
Dim Find_Start As String = "<tr><td width=""65%""><b>IP Address</b></td><td>"
Dim Find_End As String = "<"
MyIPAddressPosition_Start = InStr(WANIPAddress, Find_Start)
If (MyIPAddressPosition_Start <> 0) Then
WANIPAddress = Mid(WANIPAddress, MyIPAddressPosition_Start + Len(Find_Start))
MyIPAddressPosition_End = InStr(WANIPAddress, Find_End)
If (MyIPAddressPosition_End <> 0) Then
WANIPAddress = Mid(WANIPAddress, 1, MyIPAddressPosition_End - 1)
GetWANAddressSuccessful_Try3 = True
lg_LinkUsedToRetrieveWANIP = const_WebIPSourceToRetrieveWANAddress
End If
End If
Catch ex As Exception
GetWANAddressSuccessful_Try3 = False
WANIPAddress = ""
End Try
End Function
• What is the difference between WiFi 6 and WiFi 7?
• Yes! WiFi 7 is backwards compatible with other Wifi devices? Learn more