調べてみたらいろいろあったのでメモ。
# https://github.com/mpolden/echoip
# Star 3k
$ curl ifconfig.co
xxx.xxx.xxx.xxx
# https://ipinfo.io/about
$ curl ipinfo.io
{
"ip": "xxx.xx.xx.xx",
"hostname": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"city": "xxxxxxxx",
"region": "xxxxxxxx",
"country": "JP",
"loc": "xxxxxxxxxxxxxxxx",
"org": "xxxxxxxxxxxxxxxxxxxxxx",
"postal": "xxxxxxx",
"timezone": "Asia/Tokyo",
"readme": "https://ipinfo.io/missingauth"
}
# グローバルIPのみ取得
$ curl ipinfo.io/ip
xxx.xxx.xxx.xxx
# IPv6でアクセスするとIPv6で帰ってくる
$ curl ifconfig.io
# 明示的にIPv4を指定するには -4 をつける
$ curl ifconfig.io -4
xxx.xxx.xxx.xxx
# IPv4のみに対応
$ curl ifconfig.me
xxx.xxx.xxx.xxx
# https://github.com/masahide/inet-ip.info
$ curl inet-ip.info
xxx.xxx.xxx.xxx
# https://github.com/masahide/inet-ip.info
$ curl ipecho.net/plain
xxx.xxx.xxx.xxx
# 応答がはやい
$ ipaddr.show
xxx.xxx.xxx.xxx
# Google
$ curl https://domains.google.com/checkip
xxx.xxx.xxx.xxx
# AWS
$ curl checkip.amazonaws.com
xxx.xxx.xxx.xxx
まとめ
AWSにもグローバルIPを確認できるサービスがあった。
以下が覚えやすく使いやすかった。
- ipinfo.io
- checkip.amazonaws.com