2012年5月6日星期日

linux shell 获取计算机公网IP地址的几种写法

 
 

satan 通过 Google 阅读器发送给您的内容:

 
 

于 12-5-6 通过 averiany涂鸦馆 作者:averainy

以下是获取本地计算机的几种方法,原理很简单
1,curl "http://checkip.dyndns.org/" 2>dev/null | awk '{print $6}'|cut -d '<' -f1
2,curl -s "http://checkip.dyndns.org/" | cut -f 6 -d" " | cut -f 1 -d"<"
3,w3m -dump http://submit.apnic.net/templates/yourip.html | grep -P -o '(\d+\.){3}\d+'
4,lynx -dump http://submit.apnic.net/templates/yourip.html | grep -P -o '(\d+\.){3}\d+'
5,curl -s "http://checkip.dyndns.org/" | sed 's/.*Address: \([0-9\.]*\).*/\1/g'
6,curl -s "http://checkip.dyndns.org/" | cut -d "<" -f7|cut -c 26-
7,curl ifconfig.me
8,curl icanhazip.com
9,curl http://www.ip138.com/ips1388.asp  2>/dev/null |grep '<td align="center">' |grep '\[*\]' |cut -d "[" -f2  |cut -d "]" -f1
这些都是经过测试过的,保证能用.想使用上面的指令,确保系统安装了curl lynx w3m,grep,cut,awk 这几个包


本文作者:averainy | 本文地址: 固定链接 | 我的腾讯微博|我的google+
本站文章除特殊标明者外均为原创,版权所有,如需转载,请以超链接形式注明作者和原始出处及本声明

相关日志


 
 

可从此处完成的操作:

 
 

没有评论:

发表评论