小知识:详解几种Linux 查询外网出口IP命令的方法

Curl 纯文本格式输出:

?
1
2
3
4
5
6
7
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格式输出:

?
1
curl ipinfo.io/jsoncurl ifconfig.me/all.jsoncurl www.trackip.net/ip?json

curl XML格式输出:

?
1
curl ifconfig.me/all.xml

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

?
1
curl ifconfig.me/all

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

?
1
2
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

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

使用 host 和 dig 命令

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

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

bash 脚本示例:

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://www.cnblogs.com/wudonghang/p/354289a61129731e7d2075968356e6ad.html

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:部署前后端分离式nginx配置的完整步骤

2023-4-5 4:10:43

建站知识

小知识:利用Nginx处理Vue开发环境的跨域的方法

2023-4-5 4:19:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索