In IPv4 address scarce today, assigned to public IP is almost impossible, but my dial after the IP is a public network IP.
It is possible to use your own computer as a server and do some fun programs.
Because the operator's IP is dynamically assigned to the public network IP, it is necessary to do a dynamic analysis.
But there is no server, what should do?
The idea is to first server to obtain public IP, IP encryption as an article published to Mo A well-known forum. The client queries this article and decrypts it to get the IP
This allows for dynamic parsing of the
Because the computer also adds a router, so cannot obtain the public network IP directly, at this time need to use the third party website.
Baidu Search IP will appear
Key addresses were found through analysis
Http://2017.ip138.com/ic.asp
This page is very concise and contains IP and address
Get a public IP by crawling this address
1 Packagedynamic IP Publishing;2 3 ImportJava.io.BufferedReader;4 ImportJava.io.FileWriter;5 Importjava.io.IOException;6 ImportJava.io.InputStreamReader;7 ImportJava.io.PrintWriter;8 Importjava.net.MalformedURLException;9 ImportJava.net.URL;Ten Importjava.net.URLConnection; One A Public classMain { - Public Static voidMain (String args[]) { - System.out.println (Getip.publicip ()); the } - } - classGetIP { - Public StaticString Publicip () { +URL url =NULL; -URLConnection Urlconn =NULL; +BufferedReader br =NULL; A Try { atURL =NewURL ("http://2017.ip138.com/ic.asp");//crawl of the site is Baidu search for IP when ranked the first of the -Urlconn =url.openconnection (); -BR =NewBufferedReader (NewInputStreamReader ( - Urlconn.getinputstream ())); -String buf =NULL; -String get=NULL; in while((buf = Br.readline ())! =NULL) { -get+=buf; to } + intWhere,end; - for(Where=0;where<get.length () &&get.charat (where)! = ' ['; where++); the for(End=where;end<get.length () &&get.charat (end)! = '] '; end++); *Get=get.substring (where+1, end); $ returnget;Panax Notoginseng}Catch(malformedurlexception e) { - e.printstacktrace (); the}Catch(IOException e) { + e.printstacktrace (); A}finally { the Try { + br.close (); -}Catch(IOException e) { $ e.printstacktrace (); $ } - } - return NULL; the } -}
Java Gets the public network IP