ifconfigコマンドをインストールするには?

ショコラ
ショコラ

ifconfigコマンドをインストールするには?

「net-tools」パッケージでキメマス。
IPアドレスを確認するだけなら、ipコマンドでも確認できます。

もっさん先輩
もっさん先輩
apt-get install -y net-tools

nginxコンテナでは、なぜか「-y」のオプションを付けなくてもインストールできました。

# apt-get install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 250 kB of archives.
After this operation, 1015 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1 [250 kB]
Fetched 250 kB in 0s (1627 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package net-tools.
(Reading database ... 7823 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1_amd64.deb ...
Unpacking net-tools (1.60+git20181103.0eebece-1) ...
Setting up net-tools (1.60+git20181103.0eebece-1) ...
#

ifconfigコマンドを実行して、IPアドレスを確認できます。

ifconfig
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)
        RX packets 1537  bytes 8930755 (8.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 877  bytes 59392 (58.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 13  bytes 1594 (1.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13  bytes 1594 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
#

IPアドレスを確認するだけなら、ipコマンドでも確認できます。

ip a

シチュエーション

  • ドッカーコンテナ内で ifconfigコマンドを実行したところ、ifconfigコマンドがインストールされていなかった。「apt-get install ifconfig」を実行しても、ifconfigコマンドはインストールされなかった。
  • IPアドレスを確認したい。
Scroll to Top