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.