j3iiifn’s blog

ネットワーク、インフラ、プログラミングについての備忘録

Ubuntuでtracerouteとinetutils-tracerouteのどちらをインストールすればいいか?

Ubuntutracerouteコマンドを実行しようとすると、

$ traceroute

Command 'traceroute' not found, but can be installed with:

sudo apt install inetutils-traceroute
sudo apt install traceroute

このようにパッケージのインストールを求められるのだが、tracerouteinetutils-tracerouteのどちらをインストールすればいいのかいつも迷ってしまう。

そこで両方のパッケージを実際にインストールして、違いを調べてみた。

結論

  • とりあえず traceroute をインストールする方が無難。 こちらの方がオプションの数が多く、多機能だから。
  • tracerouteinetutils-traceroute は別物。実装が異なる。

動作確認環境

Ubuntu 18.04.2

$ uname -a
Linux raspi 4.15.0-1034-raspi2 #36-Ubuntu SMP PREEMPT Fri Apr 5 06:25:23 UTC 2019 armv7l armv7l armv7l GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

inetutils-traceroute

インストール

$ sudo apt install inetutils-traceroute
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  inetutils-traceroute
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 36.6 kB of archives.
After this operation, 240 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe armhf inetutils-traceroute armhf 2:1.9.4-3 [36.6 kB]
Fetched 36.6 kB in 1s (47.3 kB/s)
Selecting previously unselected package inetutils-traceroute.
(Reading database ... 94126 files and directories currently installed.)
Preparing to unpack .../inetutils-traceroute_2%3a1.9.4-3_armhf.deb ...
Unpacking inetutils-traceroute (2:1.9.4-3) ...
Setting up inetutils-traceroute (2:1.9.4-3) ...
update-alternatives: using /usr/bin/inetutils-traceroute to provide /usr/bin/traceroute (traceroute) in auto mode
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

コマンドのフルパス

$ which traceroute
/usr/bin/traceroute

このパスはシンボリックリンクであり、辿っていくと次のように繋がっていた。

/usr/bin/traceroute ->
/etc/alternatives/traceroute ->
/usr/bin/inetutils-traceroute

バージョン情報

$ inetutils-traceroute --version
traceroute (GNU inetutils) 1.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Elian Gidoni.

ヘルプ

$ inetutils-traceroute --help
Usage: inetutils-traceroute [OPTION...] HOST
Print the route packets trace to network host.

  -f, --first-hop=NUM        set initial hop distance, i.e., time-to-live
  -g, --gateways=GATES       list of gateways for loose source routing
  -I, --icmp                 use ICMP ECHO as probe
  -m, --max-hop=NUM          set maximal hop count (default: 64)
  -M, --type=METHOD          use METHOD (`icmp' or `udp') for traceroute
                             operations, defaulting to `udp'
  -p, --port=PORT            use destination PORT port (default: 33434)
  -q, --tries=NUM            send NUM probe packets per hop (default: 3)
      --resolve-hostnames    resolve hostnames
  -t, --tos=NUM              set type of service (TOS) to NUM
  -w, --wait=NUM             wait NUM seconds for response (default: 3)
  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to <bug-inetutils@gnu.org>.

Usage

$ inetutils-traceroute --usage
Usage: inetutils-traceroute [-I?V] [-f NUM] [-g GATES] [-m NUM] [-M METHOD]
            [-p PORT] [-q NUM] [-t NUM] [-w NUM] [--first-hop=NUM]
            [--gateways=GATES] [--icmp] [--max-hop=NUM] [--type=METHOD]
            [--port=PORT] [--tries=NUM] [--resolve-hostnames] [--tos=NUM]
            [--wait=NUM] [--help] [--usage] [--version] HOST

traceroute

インストール

$ sudo apt install traceroute
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  traceroute
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 41.1 kB of archives.
After this operation, 118 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe armhf traceroute armhf 1:2.1.0-2 [41.1 kB]
Fetched 41.1 kB in 1s (59.1 kB/s)
Selecting previously unselected package traceroute.
(Reading database ... 94126 files and directories currently installed.)
Preparing to unpack .../traceroute_1%3a2.1.0-2_armhf.deb ...
Unpacking traceroute (1:2.1.0-2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up traceroute (1:2.1.0-2) ...
update-alternatives: using /usr/bin/traceroute.db to provide /usr/bin/traceroute (traceroute) in auto mode
update-alternatives: using /usr/bin/lft.db to provide /usr/bin/lft (lft) in auto mode
update-alternatives: using /usr/bin/traceproto.db to provide /usr/bin/traceproto (traceproto) in auto mode
update-alternatives: using /usr/sbin/tcptraceroute.db to provide /usr/sbin/tcptraceroute (tcptraceroute) in auto mode

コマンドのフルパス(inetutils-tracerouteと同じ)

ubuntu@raspi:~$ which traceroute
/usr/sbin/traceroute

シンボリックリンクを辿っていくとこうなる(最後がinetutils-tracerouteと異なる)

/usr/sbin/traceroute ->
/etc/alternatives/traceroute.sbin ->
/usr/bin/traceroute.db

バージョン情報

ubuntu@raspi:~$ traceroute --version
Modern traceroute for Linux, version 2.1.0
Copyright (c) 2016  Dmitry Butskoy,   License: GPL v2 or any later

ヘルプ

$ traceroute --help
Usage:
  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]
Options:
  -4                          Use IPv4
  -6                          Use IPv6
  -d  --debug                 Enable socket level debugging
  -F  --dont-fragment         Do not fragment packets
  -f first_ttl  --first=first_ttl
                              Start from the first_ttl hop (instead from 1)
  -g gate,...  --gateway=gate,...
                              Route packets through the specified gateway
                              (maximum 8 for IPv4 and 127 for IPv6)
  -I  --icmp                  Use ICMP ECHO for tracerouting
  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80)
  -i device  --interface=device
                              Specify a network interface to operate with
  -m max_ttl  --max-hops=max_ttl
                              Set the max number of hops (max TTL to be
                              reached). Default is 30
  -N squeries  --sim-queries=squeries
                              Set the number of probes to be tried
                              simultaneously (default is 16)
  -n                          Do not resolve IP addresses to their domain names
  -p port  --port=port        Set the destination port to use. It is either
                              initial udp port value for "default" method
                              (incremented by each probe, default is 33434), or
                              initial seq for "icmp" (incremented as well,
                              default from 1), or some constant destination
                              port for other methods (with default of 80 for
                              "tcp", 53 for "udp", etc.)
  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6
                              traffic class) value for outgoing packets
  -l flow_label  --flowlabel=flow_label
                              Use specified flow_label for IPv6 packets
  -w MAX,HERE,NEAR  --wait=MAX,HERE,NEAR
                              Wait for a probe no more than HERE (default 3)
                              times longer than a response from the same hop,
                              or no more than NEAR (default 10) times than some
                              next hop, or MAX (default 5.0) seconds (float
                              point values allowed too)
  -q nqueries  --queries=nqueries
                              Set the number of probes per each hop. Default is
                              3
  -r                          Bypass the normal routing and send directly to a
                              host on an attached network
  -s src_addr  --source=src_addr
                              Use source src_addr for outgoing packets
  -z sendwait  --sendwait=sendwait
                              Minimal time interval between probes (default 0).
                              If the value is more than 10, then it specifies a
                              number in milliseconds, else it is a number of
                              seconds (float point values allowed too)
  -e  --extensions            Show ICMP extensions (if present), including MPLS
  -A  --as-path-lookups       Perform AS path lookups in routing registries and
                              print results directly after the corresponding
                              addresses
  -M name  --module=name      Use specified module (either builtin or external)
                              for traceroute operations. Most methods have
                              their shortcuts (`-I' means `-M icmp' etc.)
  -O OPTS,...  --options=OPTS,...
                              Use module-specific option OPTS for the
                              traceroute module. Several OPTS allowed,
                              separated by comma. If OPTS is "help", print info
                              about available options
  --sport=num                 Use source port num for outgoing packets. Implies
                              `-N 1'
  --fwmark=num                Set firewall mark for outgoing packets
  -U  --udp                   Use UDP to particular port for tracerouting
                              (instead of increasing the port per each probe),
                              default port is 53
  -UL                         Use UDPLITE for tracerouting (default dest port
                              is 53)
  -D  --dccp                  Use DCCP Request for tracerouting (default port
                              is 33434)
  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting
  --mtu                       Discover MTU along the path being traced. Implies
                              `-F -N 1'
  --back                      Guess the number of hops in the backward path and
                              print if it differs
  -V  --version               Print version info and exit
  --help                      Read this help and exit

Arguments:
+     host          The host to traceroute to
      packetlen     The full packet length (default is the length of an IP
                    header plus 40). Can be ignored or increased to a minimal
                    allowed value

tracerouteの方がオプションが多いから、とりあえずインストールするならtracerouteの方がオススメ。特に -A --as-path-lookups が便利。

参考URL

debian - What are the differences between iputils-ping and inetutils-ping? - Unix & Linux Stack Exchange