Introduction: In the current method of acquiring IP, the ifconfig and IP get functions are all intranet IP. Sometimes the need to obtain an external IP, the current practice is to send requests to external servers to resolve the external server response, resulting in their own external network IP. Curl under Linux can do the work for us, of course, not afraid of trouble, you can analyze the HTTP protocol yourself, to achieve the above process. If you're familiar with Python, it's even easier, as we all know, Python always has a library function ready for us to call. A summary of several methods to obtain the external network IP for query, data source Internet.
See information:
Http://www.cnblogs.com/nhlinkin/p/3535214.html
Http://www.2cto.com/os/201302/190269.html
$ Curl Ifconfig.me
$ Curl Icanhazip.com
$ Curl Ident.me
$ Curl Ipecho.net/plain
$ Curl Whatismyip.akamai.com
$ Curl TNX.NL/IP
$ Curl Myip.dnsomatic.com
$ Curl Ip.appspot.com
$ curl-s checkip.dyndns.org | Sed ' s/.*ip Address: \ ([0-9\.] *\). */\1/g '
$ Curl Http://ip.3322.net
$ Curl Icanhazip.com
Method One: Curl-s "http://checkip.dyndns.org/" |cut-f 6-d "|cut-f 1-d" < "Www.2cto.com Method II: W3m-dump HTTP://SUBMI t.apnic.net/templates/yourip.html | Grep-p-O ' (\d+\.) {3}\d+ ' method three: Curl Ifconfig.me method Four: Curl Icanhazip.com method Five: Curl-s www.123cha.com | Grep-o "[0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} ' | Head-n 1 add them to. BASHRC (bash dedicated) or. Profile (not bash dedicated) go to alias myip= ' Curl ifconfig.me ' source. BASHRC or. The. Profile will take effect input Myip to get WAN IP.
Linux Get extranet IP