0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Linux】ifconfig と grep コマンドを使ってプライベートIPアドレスを簡単に見つける方法

Last updated at Posted at 2024-02-28

はじめに

この記事では、ifconfigとgrepコマンドを組み合わせることで、特にプライベートIPアドレスを簡単に見つける方法についてご紹介します。

環境

  • Apple M2 Pro
  • macOS Sonoma 14.2.1

IPアドレスの検索

多くのローカルネットワークでは、プライベートIPアドレスは 192.168.x.x の形式かと思います。

この範囲のIPアドレスを検索するには、次のコマンドを実行します。

ifconfig | grep 192

このコマンドで行われることは以下の通りです。

  • ifconfig コマンドが実行され、そのパソコンのIPネットワークの設定情報が表示されます。
  • |(パイプ)は、ifconfig の出力を grep コマンドに渡します。
  • grep 192 は、その出力の中から 192 で始まる行のみを抽出し、表示します。

これにより、プライベートIPアドレスなど、192で始まる情報だけを簡単に見つけることができます。

出力例(例なので適当に書き換えています)

inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255

この例では、プライベートIPアドレスが 192.168.1.5 であることがわかります。また、netmask と broadcast の情報も表示されています。

まとめ

ifconfig と grep コマンドを組み合わせることで、プライベートIPアドレスを簡単に見つけることができました。

参考

0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?