ifconfigは、Linuxマシンに接続されているネットワークインターフェイスと、ネットワークインターフェイスに割り当てられているIPアドレスやネットマスクなどのネットワーク情報を表示するためのコマンドラインユーティリティです。
また、送受信されたネットワークパケットの数と、エラーおよびドロップされたパケットの数が表示されます。
CentOS 8 / RHEL 8の最小インストールを実行すると、ifconfigコマンドを実行したときにコマンドが見つからないなどのエラーが発生する場合があります。
読む: CentOS 8のインストール方法–ステップバイステップガイド(スクリーンショット付き)
読む: RHEL 8のインストール方法–ステップバイステップガイド(スクリーンショット付き)
-bash: ifconfig: command not found
このガイドは、ifconfigコマンドを取得するために必要なパッケージをインストールするのに役立ちます。
ifconfigパッケージをインストールする
YUMコマンドを使用してifconfigコマンドを提供するパッケージを見てみましょう。
yum whatprovides ifconfig
出力:
CentOS-8 - AppStream 1.1 MB/s | 6.3 MB 00:05 CentOS-8 - Base 954 kB/s | 7.9 MB 00:08 CentOS-8 - Extras 569 B/s | 2.1 kB 00:03 Extra Packages for Enterprise Linux 8 - x86_64 617 kB/s | 3.2 MB 00:05 net-tools-2.0-0.51.20160912git.el8.i686 : Basic networking tools Repo : BaseOS Matched from: Filename : /usr/sbin/ifconfig net-tools-2.0-0.51.20160912git.el8.x86_64 : Basic networking tools Repo : BaseOS Matched from: Filename : /usr/sbin/ifconfig
上記のコマンドから、net-toolsパッケージがifconfigコマンドを提供していることがわかります。次に、yumコマンドを使用してnet-toolsパッケージをインストールします。
yum -y install net-tools
出力:
Last metadata expiration check: 0:00:51 ago on Mon 04 Nov 2019 09:07:03 AM EST. Dependencies resolved. ========================================================================================= Package Arch Version Repository Size ========================================================================================= Installing: net-tools x86_64 2.0-0.51.20160912git.el8 BaseOS 323 k Transaction Summary ========================================================================================= Install 1 Package Total download size: 323 k Installed size: 1.0 M Downloading Packages: net-tools-2.0-0.51.20160912git.el8.x86_64.rpm 264 kB/s | 323 kB 00:01 ----------------------------------------------------------------------------------------- Total 148 kB/s | 323 kB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Running scriptlet: net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Verifying : net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Installed: net-tools-2.0-0.51.20160912git.el8.x86_64 Complete!
インストールが完了したら、ifconfigを実行して、使用可能かどうかを確認します。
ifconfig
出力:
結論
それで全部です。これで、CentOS 8 /RHEL8マシンでifconfigコマンドを使用できるようになりました。