linux – 如何在shell脚本中获取公共IP地址?

linux – 如何在shell脚本中获取公共IP地址?,第1张

概述此命令返回我的IP地址以及其他信息. dig @resolver1.opendns.com myip.opendns.com; <<>> DiG 9.6-ESV-R4-P3 <<>> @resolver1.opendns.com myip.opendns.com; (1 server found);; global options: +cmd;; Got answer:;; ->>HEA 此命令返回我的IP地址以及其他信息.
dig @resolver1.opendns.com myip.opendns.com; <<>> DiG 9.6-ESV-R4-P3 <<>> @resolver1.opendns.com myip.opendns.com; (1 server found);; global options: +cmd;; Got answer:;; ->>header<<- opcode: query,status: NOERROR,ID: 48206;; flags: qr rd ra; query: 1,ANSWER: 1,AUTHORITY: 0,ADDITIONAL: 0;; QUESTION SECTION: ;myip.opendns.com.      IN  A;; ANSWER SECTION:myip.opendns.com.   0   IN  A   122.167.119.178;; query time: 199 msec;; SERVER: 208.67.222.222#53(208.67.222.222);; WHEN: Fri May 18 11:46:51 2012;; MSG SIZE  rcvd: 50

我只想从中提取我的IP地址.如何从dig输出中提取我的ip地址?

解决方法 不要让它变得比它需要的更难……使用时间短
[mpenning@Bucksnort ~]$dig +short mike.homeunix.com76.21.48.169[mpenning@Bucksnort ~]$
总结

以上是内存溢出为你收集整理的linux – 如何在shell脚本获取公共IP地址?全部内容,希望文章能够帮你解决linux – 如何在shell脚本中获取公共IP地址?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1048232.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存