Get TP-LINK router Internet IP address directly

Source: Internet
Author: User

To obtain the Internet (or public) IP address of a vro, you must first access a website on the Internet (for example, record the Internet IP address of the vro by this website, and then return the result. In fact, for some models of the router, we can directly read its Internet IP, such as the TP-LINK, the following is the VB. NET implementation code, with a connection and disconnection two sections of the Code:

''' <Summary> ''' connect to the internet ''' </Summary> Public sub connect (byval username as string, byval password as string) dim xhttp as object = Createobject ("msxml2.xmlhttp") xhttp. open ("get", "http: // 192.168.2.2/userrpm/statusrpm.htm? Connect = connection & Wan = 1 ", false, username, password) xhttp. send () system. runtime. interopservices. marshal. releasecomobject (xhttp) xhttp = nothing end sub ''' <summary> ''' disconnect the Internet ''' </Summary> Public sub disconnect (byval username as string, byval password as string) dim xhttp as object = Createobject ("msxml2.xmlhttp") xhttp. open ("get", "http: // 192.168.2.2/userrpm/statusrpm.htm? Disconnect = disconnected & Wan = 1 ", false, username, password) xhttp. send () system. runtime. interopservices. marshal. releasecomobject (xhttp) xhttp = nothing end sub ''' <summary> ''' get Internet IP ''' </Summary> Public Function getwanip (byval username as string, byval password as string) as string dim strip as string = "0.0.0.0" dim xhttp as object = Createobject ("msxml2.xmlhttp") xhttp. open ("get", "http: // 192.168.2.2/u Serrpm/statusrpm.htm? Connect = connection & Wan = 1 ", false, username, password) xhttp. send () If xhttp. readystate = 4 andalso xhttp. status = 200 then dim strhtml as string = text. encoding. default. getstring (xhttp. responsebody) strhtml = strhtml. substring (strhtml. indexof ("Var wanpara") strhtml = strhtml. substring (0, strhtml. indexof (";") strip = strhtml. split (",") (2 ). replace ("""",""). trim () end if system. runtime. interopservices. marshal. releasecomobject (xhttp) xhttp = nothing return strip end Function

In addition, some friends may have seen connection to the Internet and disconnection from the Internet in some blogs, and I still mark it as "original" here ", the reason is that I did not find similar code and wrote it after intercepting and analyzing HTTP data packets. Later, I found similar code on the Internet, which is probably "slightly different from heroes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.