获取主机公网ip的几种方法

1. 获取主机公网ip的几种方法

1.使用ifconfig.io

1
2
[root@linux ~]# curl ifconfig.io
35.198.213.87

2.使用ifconfig.me

1
2
[root@linux ~]# curl ifconfig.me
35.198.213.87

3.使用ifconfig.co

1
2
[root@linux ~]# curl ifconfig.co
35.198.213.87

4.使用ident.me

1
2
[root@linux ~]# curl ident.me
35.198.213.87

5.使用ip.sb

1
2
[root@linux ~]# curl ip.sb
35.198.213.87

6.使用ipinfo.io

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@linux ~]# curl ipinfo.io
{
"ip": "35.198.213.87",
"hostname": "87.213.198.35.bc.googleusercontent.com",
"city": "Singapore",
"region": "Singapore",
"country": "SG",
"loc": "1.2897,103.8501",
"org": "AS15169 Google LLC",
"postal": "048508",
"timezone": "Asia/Singapore",
"readme": "https://ipinfo.io/missingauth"
}

如果这需要取出ip可以用ipinfo.io/ip

1
2
[root@linux ~]# curl ipinfo.io/ip
35.198.213.87

7.使用icanhazip.com

1
2
[root@linux ~]# curl icanhazip.com
35.198.213.87

8.使用myio.ipip.net

1
2
[root@linux ~]# curl myip.ipip.net
当前 IP:35.198.213.87 来自于:新加坡 新加坡 cloud.google.com

9.使用checkip.dyndns.org

1
2
[root@linux ~]# curl checkip.dyndns.org
<html><head><title>Current IP Check</title></head><body>Current IP Address: 35.198.213.87</body></html>

如果这里只想取出IP可以执行下面的命令

1
2
[root@linux ~]# curl "http://checkip.dyndns.org/" 2>/dev/null|awk '{print $6}'|cut -d '<' -f1
35.198.213.87

10.使用cip.cc

1
2
3
4
5
6
7
8
9
[root@linux ~]# curl cip.cc 
IP : 35.198.213.87
地址 : 新加坡 新加坡

数据二 : 新加坡 | Google云计算数据中心

数据三 : 新加坡 | 谷歌

URL : http://www.cip.cc/35.198.213.87
-------------本文结束感谢您的阅读-------------