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

2023-11-27 0 183

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,若引用不当,请联系修改。

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 4975 +

    运行天数

你的前景,远超我们想象