【Linux】curlでグローバルIPを確認 (まとめ)

snow
2021-03-30
snow
2021-03-30

# ifconfig.io ifconfig.me

```
$ curl ifconfig.io
92.203.52.140
$ curl ifconfig.me
92.203.52.140
IPv4 固定
$ curl ifconfig.io -4
92.203.52.140
$ curl ifconfig.me -4
92.203.52.140

$ curl ifconfig.io/all.json
{
"country_code": "JP",
"encoding": "gzip",
"forwarded": "92.203.52.140",
"ifconfig_hostname": "ifconfig.io",
"ip": "92.203.52.140",
"lang": "",
"method": "GET",
"mime": "*/*",
"port": 2538,
"referer": "",
"ua": "curl/7.64.1"
}
```

# ipinfo.io

```
$ curl ipinfo.io
{
"ip": "92.203.52.140",
"hostname": "fp5ccb348c.fkol216.ap.nuro.jp",
"city": "Tokyo",
"region": "Tokyo",
"country": "JP",
"loc": "35.6910,139.7679",
"org": "AS2527 Sony Network Communications Inc.",
"postal": "101-0047",
"timezone": "Asia/Tokyo",
"readme": "https://ipinfo.io/missingauth"
}
```

# inet-ip.info

```
$ curl inet-ip.info
92.203.52.140

$ curl inet-ip.info/ip
92.203.52.140

$ curl inet-ip.info/json
{
"IP": "92.203.52.140",
"Hostname": "[fp5ccb348c.fkol216.ap.nuro.jp.]",
"CountryCode": "DE",
"CountryName": "Germany",
"Accept": ["*/*"],
"AcceptEncoding": null,
"AcceptLanguage": null,
"UserAgent": ["curl/7.64.1"],
"Via": null,
"XForwardedFor": ["92.203.52.140"],
"XForwardedPort": null,
"XForwardedProto": ["http"],
"RequestURI": "/json"
}
```

# ip-api.com

```
$ curl ip-api.com
{
"status" : "success",
"continent" : "Asia",
"continentCode": "AS",
"country" : "Japan",
"countryCode" : "JP",
"region" : "40",
"regionName" : "Fukuoka",
"city" : "Fukuoka",
"district" : "",
"zip" : "819-0001",
"lat" : 33.5895,
"lon" : 130.3197,
"timezone" : "Asia/Tokyo",
"offset" : 32400,
"currency" : "JPY",
"isp" : "Sony Network Communications Inc",
"org" : "Sony Network Communications Inc.",
"as" : "AS2527 Sony Network Communications Inc.",
"asname" : "SO-NET",
"mobile" : false,
"proxy" : false,
"hosting" : false,
"query" : "92.203.52.140"
}
```

# httpbin.org

```
$ curl httpbin.org/ip
{
"origin": "92.203.52.140"
}
```

余談:

digコマンドの場合
```
$ dig o-o.myaddr.l.google.com @ns1.google.com txt +short
"92.203.52.140"

$ dig myip.opendns.com @resolver1.opendns.com +short
92.203.52.140
```