WSL(Ubuntu 20.04.2 LTS)にtracerouteをインストールする

# はじめに
こんにちは。先日地元の服屋さんで、あ、この靴下いいな :smile: と思った靴下の値段が50円でした。2個買いました、筆者です :yum:

さて、今回は後続で記事にするかもですが、ちょっとネットワーク周り見てまして、**traceroute**コマンド使おうとしたら、「**入ってないからインストールしてね**」と言われたので、入れました。

そして、なんか2つサジェストされて、どっちインストールすればいいか迷ったため、記事にします。
どなたかの参考になれば幸いです:pray:

# traceroute使おうとしたら...
**入ってないからインストールしてね**とのこと。
そしてなんか2つある:thinking: 

**<font color="red">え、どっちが正解？</font>**

```sh
$ traceroute -h

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

sudo apt install inetutils-traceroute  # version 2:1.9.4-11, or
sudo apt install traceroute            # version 1:2.1.0-2
```

# 結論
**traceroute**をインストールする方がよさそう。

# 詳細

## 1. とりあえずaptで問い合わせてみる.

同じようなこと言ってますね...。
(この時点でどっちでもやりたいことはできるんだろうなと思いました:thinking:)

### inetutils-traceroute

```sh
$ sudo apt show inetutils-traceroute

Package: inetutils-traceroute
Version: 2:1.9.4-11
Priority: extra
Section: universe/net
Source: inetutils
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Guillem Jover <guillem@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 272 kB
Provides: traceroute
Depends: libc6 (>= 2.15), libidn11 (>= 1.13), netbase
Homepage: https://www.gnu.org/software/inetutils/
Download-Size: 41.9 kB
APT-Sources: http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Description: trace the IPv4 route to another host
 The traceroute utility displays the route taken by IP packets on their
 way to another host or another network.
 .
 Install this package if you need a tool to examine network connectivity
 or to diagnose network problems.
```

### traceroute

```sh
$ sudo apt show traceroute
Package: traceroute
Version: 1:2.1.0-2
Priority: optional
Section: universe/net
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 152 kB
Depends: libc6 (>= 2.14)
Homepage: http://traceroute.sourceforge.net/
Download-Size: 45.4 kB
APT-Sources: http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Description: Traces the route taken by packets over an IPv4/IPv6 network
 The traceroute utility displays the route used by IP packets on their way to a
 specified network (or Internet) host. Traceroute displays the IP number and
 host name (if possible) of the machines along the route taken by the packets.
 Traceroute is used as a network debugging tool. If you're having network
 connectivity problems, traceroute will show you where the trouble is coming
 from along the route.
 .
 Install traceroute if you need a tool for diagnosing network connectivity
 problems.
```

## 2. 上記に記載の**Homepage**見てみよう.
どっちも使えそう。気になるのは、**traceroute**はここ5年くらい更新がないけど、**inetutils-traceroute**は昨年(2020年)に更新がされている点:thinking:

メンテされているほうが個人的にはうれしい:pray:

### inetutils-traceroute

https://www.gnu.org/software/inetutils/

### traceroute

http://traceroute.sourceforge.net/

## 3. 両方使ってみるか.

### inetutils-traceroute

```sh
$ sudo apt install inetutils-traceroute
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libidn11
The following NEW packages will be installed:
  inetutils-traceroute libidn11
0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
Need to get 88.1 kB of archives.
After this operation, 522 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libidn11 amd64 1.33-2.2ubuntu2 [46.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 inetutils-traceroute amd64 2:1.9.4-11 [41.9 kB]
Fetched 88.1 kB in 6s (14.8 kB/s)
Selecting previously unselected package libidn11:amd64.
(Reading database ... 33062 files and directories currently installed.)
Preparing to unpack .../libidn11_1.33-2.2ubuntu2_amd64.deb ...
Unpacking libidn11:amd64 (1.33-2.2ubuntu2) ...
Selecting previously unselected package inetutils-traceroute.
Preparing to unpack .../inetutils-traceroute_2%3a1.9.4-11_amd64.deb ...
Unpacking inetutils-traceroute (2:1.9.4-11) ...
Setting up libidn11:amd64 (1.33-2.2ubuntu2) ...
Setting up inetutils-traceroute (2:1.9.4-11) ...
update-alternatives: using /usr/bin/inetutils-traceroute to provide /usr/bin/traceroute (traceroute) in auto mode
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
```

ヘルプ出してみる.

```sh
$ sudo traceroute --help
Usage: 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>.
```

### traceroute

```sh
$ 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 6 not upgraded.
Need to get 45.4 kB of archives.
After this operation, 152 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 traceroute amd64 1:2.1.0-2 [45.4 kB]
Fetched 45.4 kB in 3s (16.2 kB/s)
Selecting previously unselected package traceroute.
(Reading database ... 33062 files and directories currently installed.)
Preparing to unpack .../traceroute_1%3a2.1.0-2_amd64.deb ...
Unpacking traceroute (1:2.1.0-2) ...
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
Processing triggers for man-db (2.9.1-1) ...
```

ヘルプ出してみる.

```sh
$ 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
```

## 4. 両方使ってみた結果.
**inetutils-traceroute**が個人的な感覚かもですが、動きが重かったです:thinking:
それに比べて、**traceroute**の方がサクサク動きます。

検証時、ネットの速度は45Mbpsくらい出てたので、そこそこの速度は出ていたのと、同じ通信状況で確認したのと、検証に使用したドメインも同一であるため、**traceroute**の方がいいなという所感です。
(検証に使用したドメインはAWSのCloudFrontで返却しているので、たまたま別のキャッシュサーバが返却しているかので可能性はあるかもです...。ちょっとそこは確認もれました、すみません:bow:)


# おわりに
こちらの記事を参考にさせていただきました。

https://blog.pinkumohikan.com/entry/how-to-install-traceroute-command-to-ubuntu18

私が試した際には、どちらも目的のホストに到達できたので、どちらを使っても問題はないと思います。

ただ、個人的に、両方使ってみた感想ですと、**traceroute**がよかったです！
という結論になりました:pray:
(本当はもっとちゃんとした理由でこれだ！って言いたいのですが、そこに落とし込めませんでした:bow:)

参考になれば幸いです:pray: