ネットワーク関連基本コマンドのインストール

Debian さくらのVPS

Debian をインストールしたとき、ifconfig, netstat, route など、 ネットワーク関連(?)の基本コマンドがインストールされていないことに 気がついた。
気持ち悪いので、インストールしておく。

どのパッケージをインストールすれば良い?

yasunari@sakura:~$ apt-cache search ifconfig
gnome-nettool - GNOME 用ネットワーク情報ツール
inetutils-tools - 基本的なネットワークユーティリティ群 (実験的パッケージ)
iproute2 - ネットワークおよびトラフィック制御ツール
moreutils - 追加の Unix ユーティリティ
net-tools - NET-3 ネットワークツールキット
wmifinfo - インターフェイス全ての情報を表示する Dockapp
libnet-ifconfig-wrapper-perl - multiplatform Perl wrapper for ifconfig
libnet-interface-perl - Perl module for manipulating host network interfaces
libsys-hostip-perl - Perl module to determine local machine's IP address
python-sh - Python subprocess interface
python3-sh - Python 3 subprocess interface
yasunari@sakura:~$
よくわからない。。。

どのパッケージに入っているかは、apt-file で調べられるらしい。

yasunari@sakura:~$ apt-file search ifconfig
-bash: apt-file: コマンドが見つかりません
yasunari@sakura:~$ sudo apt-get install apt-file
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  libapt-pkg-perl libexporter-tiny-perl liblist-moreutils-perl libregexp-assemble-perl
以下のパッケージが新たにインストールされます:
  apt-file libapt-pkg-perl libexporter-tiny-perl liblist-moreutils-perl
  libregexp-assemble-perl
アップグレード: 0 個、新規インストール: 5 個、削除: 0 個、保留: 0 個。
286 kB のアーカイブを取得する必要があります。
この操作後に追加で 769 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://ftp.jp.debian.org/debian stretch/main amd64 libapt-pkg-perl amd64 0.1.32 [68.7 kB]
	:
	:
apt-file (3.1.4) を設定しています ...
The system-wide cache is empty. You may want to run 'apt-file update'
as root to update the cache.
yasunari@sakura:~$
まずは、アップデートか。。。
yasunari@sakura:~$ sudo apt-file update
取得:1 http://security.debian.org/debian-security stretch/updates InRelease [63.0 kB]
無視:2 http://ftp.jp.debian.org/debian stretch InRelease
ヒット:3 http://ftp.jp.debian.org/debian stretch Release
取得:4 http://security.debian.org/debian-security stretch/updates/main Sources [108 kB]
取得:5 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [269 kB]
取得:7 http://ftp.jp.debian.org/debian stretch/main amd64 Contents (deb) [31.4 MB]
31.9 MB を 14秒 で取得しました (2,152 kB/s)
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
パッケージはすべて最新です。
yasunari@sakura:~$ 
今度こそ
yasunari@sakura:~$ apt-file search ifconfig
	:
	:
net-tools: /sbin/ifconfig
	:
	:
yasunari@sakura:~$
net-tools をインストールすれば良いらしい。

ifconfig のインストール

yasunari@sakura:~$ sudo apt-get install net-tools
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  net-tools
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
248 kB のアーカイブを取得する必要があります。
この操作後に追加で 963 kB のディスク容量が消費されます。
取得:1 http://ftp.jp.debian.org/debian stretch/main amd64 net-tools amd64 1.60+git20161116.90da8a0-1 [248 kB]
248 kB を 0秒 で取得しました (7,329 kB/s)
以前に未選択のパッケージ net-tools を選択しています。
(データベースを読み込んでいます ... 現在 34079 個のファイルとディレクトリがインストールされて います。)
.../net-tools_1.60+git20161116.90da8a0-1_amd64.deb を展開する準備をしています ...
net-tools (1.60+git20161116.90da8a0-1) を展開しています...
man-db (2.7.6.1-2) のトリガを処理しています ...
net-tools (1.60+git20161116.90da8a0-1) を設定しています ...
yasunari@sakura:~$
実行してみる
yasunari@sakura:~$ /sbin/ifconfig -a
ens3: flags=4163  mtu 1500
        inet 内緒  netmask 255.255.254.0  broadcast 内緒
        inet6 内緒  prefixlen 64  scopeid 0x0
        inet6 内緒  prefixlen 64  scopeid 0x20
        ether 内緒  txqueuelen 1000  (イーサネット)
        RX packets 253054  bytes 49261260 (46.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12027  bytes 1012643 (988.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens4: flags=4098  mtu 1500
        ether 内緒  txqueuelen 1000  (イーサネット)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens5: flags=4098  mtu 1500
        ether 内緒  txqueuelen 1000  (イーサネット)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (ローカルループバック)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

yasunari@sakura:~$
こうでないとね。

netstat のインストール

yasunari@sakura:~$ apt-file search /sbin/netstat
yasunari@sakura:~$ apt-file search /usr/sbin/netstat
yasunari@sakura:~$ apt-file search /bin/netstat
net-tools: /bin/netstat
netstat-nat: /usr/bin/netstat-nat
yasunari@sakura:~$
net-tools に入っているということは、もうインストールできている?
yasunari@sakura:~$ netstat -r
カーネルIP経路テーブル
受信先サイト    ゲートウェイ    ネットマスク   フラグ   MSS Window  irtt インタフェース
default         内緒            0.0.0.0         UG        0 0          0 ens3
localnet        0.0.0.0         255.255.254.0   U         0 0          0 ens3
yasunari@sakura:~$
OK

route

yasunari@sakura:~$ apt-file search /bin/route
iproute2: /usr/bin/routef
iproute2: /usr/bin/routel
yasunari@sakura:~$ apt-file search /sbin/route
net-tools: /sbin/route
yasunari@sakura:~$
と、これも net-tools
yasunari@sakura:~$ /sbin/route
カーネルIP経路テーブル
受信先サイト    ゲートウェイ    ネットマスク   フラグ Metric Ref 使用数 インタフェース
default         内緒            0.0.0.0         UG        0 0          0 ens3
localnet        0.0.0.0         255.255.254.0   U     0      0        0 ens3
yasunari@sakura:~$
OK

あぁ気持ちいい。。。

しかしまぁ Debian のインストーラはなぜこんな基本的なパッケージをインストールしてくれなかったの??



sudo のセットアップ
山下康成の
雲の上

rsync のインストール

Copyright (C) 2003-2018 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市/東京都新宿区