当前位置: 首页 > 技术支持 > 服务器维护>> Linux系统中查看外网ip的不同方法

Linux系统中查看外网ip的不同方法

Linux系统中查看外网ip的不同方法

Linux系统中如何查看外网ip?本篇文章将通过不同的方法为大家分享一下Linux系统中查看外网ip的具体方法, 有需要的小伙伴可以参考一下。

Curl 纯文本格式输出:

 curl icanhazip.com   curl ifconfig.me   curl curlmyip.com   curl ip.appspot.com   curl ipinfo.io/ip   curl ipecho.net/plain   curl www.trackip.net/i

curl JSON格式输出:

 curl ipinfo.io/json   curl ifconfig.me/all.json   curl www.trackip.net/ip?json (有点丑陋)

curl XML格式输出:

 curl ifconfig.me/all.xml

curl 得到所有IP细节 (挖掘机)

 curl ifconfig.me/all

使用 DYDNS (当你使用 DYDNS 服务时有用)

 curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: ([0-9.]*).*/1/g'   curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]+"

使用 Wget 代替 Curl

 wget http://ipecho.net/plain -O - -q ; echo   wget http://observebox.com/ip -O - -q ; echo

使用 host 和 dig 命令

如果有的话,你也可以直接使用 host 和 dig 命令。

 host -t a dartsclink.com | sed 's/.*has address //'   dig +short myip.opendns.com @resolver1.opendns.com

bash 脚本示例:

 #!/bin/bash   PUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`   echo $PUBLIC_IP

至此关于Linux系统查看外网ip的方法分享结束,大家有任何问题都可以通过评论区将问题提交给我们。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你!

本文来源:www.lxlinux.net/1533.html,若引用不当,请联系修改。


服务器购买/咨询热线:1563700917115617636856

本文链接:http://43.134.181.216/jishuzhichiyuweihu/12379.html
tags:LinuxVPSIPLinux系统HTTPHTTPSHTMLUbuntuXML
腾讯云服务器特惠

  • 关注微信
是否收录:

猜你喜欢

微信公众号