当前位置: 移动技术网 > 网络运营>服务器>Linux > 详解几种Linux 查询外网出口IP命令的方法

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

2019年04月24日  | 移动技术网网络运营  | 我要评论
curl 纯文本格式输出: curl icanhazip.com curl ifconfig.me curl curlmyip.com curl 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/jsoncurl ifconfig.me/all.jsoncurl 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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网