LoginSignup
30
24

More than 5 years have passed since last update.

使っている環境のグローバルIPアドレスを調べるコマンド

Posted at

確認くんなどが有名だが、コマンド一発で知りたい場合に便利。

ifconfig.meというサイトで使っている環境のグローバルIPがわかる。

使っている環境のグローバルIPアドレスを調べる
$ curl -s ifconfig.me
シェルスクリプトに組み込む
#!/bin/sh

MYIP=`curl -s ifconfig.me`

echo $MYIP

AWSのインスタンスに割り当てられているグローバルIPを取得する場合、メタ情報にアクセスすれば取得できる。

AWSのインスタンスに割り当てられているグローバルIPを取得
$ curl -s http://169.254.169.254/latest/meta-data/public-ipv4
30
24
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
24