whoisコマンドを使ってみる

# 0.本稿について
- 環境：本稿ではAlmaLinux9.xをMinimalで最小インストールした環境を使用しています。

:::note warn 
#### 正確さの省略について
本稿では概念をわかりやすくするために、簡略化した表現を使用し、一部専門的な詳細を省略している事があります。
:::

# 1.はじめに
インターネットの世界で使われているドメイン名やIPアドレスは、レジストリの持つデータベースに登録されています。

このデータベースは、例えば以下のようなサイトから検索する事が可能です。

https://www.nic.ad.jp/ja/whois/ja-gateway.html

もう一つの方法として、`whois`コマンドを使って検索する方法があります。
本稿ではこの`whois`コマンドを使って検索する方法を少し紹介します。

お品書き
- 2.whoisのパッケージ
- 3.whoisのインストール
- 4.早速調べてみよう


# 2. whoisのパッケージ
minimal環境なので、最早いつものごとくなのですが、まずはwhoisコマンドが入っているか確認します。

```bash
which whois
```
```bash
/usr/bin/which: no whois in (/home/yoyo/.local/bin:/home/yoyo/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
```
続いて、whoisコマンドの入っているパッケージを探してみます。

```bash
dnf provides whois
```
```bash
whois-5.5.9-4.el9.x86_64 : Improved WHOIS client
Repo        : appstream
一致:
提供する    : whois = 5.5.9-4.el9
```
どうやらappstreamレポジトリから、コマンドと同名のパッケージで提供されているようです。

# 3.whoisコマンドのインストール

以下コマンドでwhoisのインストールを行います。

```bash
dnf install whois -y
```

whichコマンドで見てみるとインストールされていそうです。

```bash
which whois
/usr/bin/whois
```

dnfコマンド実行時にバージョンが表示されていたので見る必要はありませんが、以下コマンドでwhoisのバージョンが分かります。

```bash
whois --version
バージョン 5.5.9.
```

# 4.調べてみよう
早速`whois`コマンドを使って調べてみましょう。試しに東京大学の`u-tokyo.ac.jp`を調べてみます。
```bash
whois u-tokyo.ac.jp
```
```bash
[ JPRS database provides information on network administration. Its use is    ]
[ restricted to network administration purposes. For further information,     ]
[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e'     ]
[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'.                 ]
Domain Information: [ドメイン情報]
a. [ドメイン名]                 U-TOKYO.AC.JP
e. [そしきめい]
f. [組織名]                     東京大学
g. [Organization]               University of Tokyo
k. [組織種別]                   国立大学
l. [Organization Type]          National University
m. [登録担当者]                 MN010JP
n. [技術連絡担当者]             MN010JP
n. [技術連絡担当者]             YS7474JP
p. [ネームサーバ]               dns1.nc.u-tokyo.ac.jp
p. [ネームサーバ]               dns2.nc.u-tokyo.ac.jp
p. [ネームサーバ]               dns3.nc.u-tokyo.ac.jp
p. [ネームサーバ]               dns-x.sinet.ad.jp
s. [署名鍵]
[状態]                          Connected (2025/03/31)
[登録年月日]
[接続年月日]                    2020/06/08
[最終更新]                      2024/04/01 01:03:45 (JST)
```
JPRSのデータベースから引っ張ってくれました。nsを4つ持っていて、一つはsinet(学術情報ネットワーク)のnsのように見えます。
今度はnasaの`nasa.gov`を調べてみましょう。
```bash
whois nasa.gov
```
```bash
Domain Name: nasa.gov
Registrar WHOIS Server: whois.nic.gov
Registrar URL: https://get.gov
Updated Date: 2024-09-30T14:00:09Z
Creation Date: 1997-10-02T01:29:26Z
Registry Expiry Date: 2025-08-30T18:16:33Z
Registrar: get.gov
Registrar IANA ID: 8888888
Registrar Abuse Contact Email:
Registrar Abuse Contact Phone:
Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
Registry Registrant ID: REDACTED FOR PRIVACY
Registrant Name: REDACTED FOR PRIVACY
Registrant Organization: REDACTED FOR PRIVACY
Registrant Street: REDACTED FOR PRIVACY
Registrant Street: REDACTED FOR PRIVACY
Registrant City: REDACTED FOR PRIVACY
Registrant State/Province: REDACTED FOR PRIVACY
Registrant Postal Code: REDACTED FOR PRIVACY
Registrant Country: REDACTED FOR PRIVACY
Registrant Phone: REDACTED FOR PRIVACY
Registrant Email: REDACTED FOR PRIVACY
Registry Admin ID: REDACTED FOR PRIVACY
Admin Name: REDACTED FOR PRIVACY
Admin Organization: REDACTED FOR PRIVACY
Admin Street: REDACTED FOR PRIVACY
Admin Street: REDACTED FOR PRIVACY
Admin City: REDACTED FOR PRIVACY
Admin State/Province: REDACTED FOR PRIVACY
Admin Postal Code: REDACTED FOR PRIVACY
Admin Country: REDACTED FOR PRIVACY
Admin Phone: REDACTED FOR PRIVACY
Admin Email: REDACTED FOR PRIVACY
Registry Tech ID: REDACTED FOR PRIVACY
Tech Name: REDACTED FOR PRIVACY
Tech Organization: REDACTED FOR PRIVACY
Tech Street: REDACTED FOR PRIVACY
Tech City: REDACTED FOR PRIVACY
Tech State/Province: REDACTED FOR PRIVACY
Tech Postal Code: REDACTED FOR PRIVACY
Tech Country: REDACTED FOR PRIVACY
Tech Phone: REDACTED FOR PRIVACY
Tech Fax: REDACTED FOR PRIVACY
Tech Email: REDACTED FOR PRIVACY
Registry Security ID: REDACTED FOR PRIVACY
Security Name: REDACTED FOR PRIVACY
Security Organization: REDACTED FOR PRIVACY
Security Street: REDACTED FOR PRIVACY
Security City: REDACTED FOR PRIVACY
Security State/Province: REDACTED FOR PRIVACY
Security Postal Code: REDACTED FOR PRIVACY
Security Country: REDACTED FOR PRIVACY
Security Phone: REDACTED FOR PRIVACY
Security Email: soc@nasa.gov
Name Server: a1-32.akam.net
Name Server: a12-64.akam.net
Name Server: a14-67.akam.net
Name Server: a5-66.akam.net
Name Server: a8-66.akam.net
Name Server: a9-64.akam.net
DNSSEC: signedDelegation
>>> Last update of WHOIS database: 2025-01-30T04:23:38Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

WHOIS information is provided by the registry solely for query-based,
informational purposes. Any information provided is "as is" without any
guarantee of accuracy. You may not use such information to (a) allow,
enable, or otherwise support the transmission of mass unsolicited,
commercial advertising or solicitations; (b) enable high volume, automated,
electronic processes that access the registry's systems or any
ICANN-Accredited Registrar, except as reasonably necessary to register
domain names or modify existing registrations; or (c) engage in or support
unlawful behavior. We reserve the right to restrict or deny your access to
the WHOIS database, and may modify these terms at any time.
```

日本の物とは表示形式が大きく異なります。
今度は有名なパブリックDNSの`8.8.8.8`を見てみましょう。
```bash
whois 8.8.8.8
```
```bash
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/
#
# Copyright 1997-2025, American Registry for Internet Numbers, Ltd.
#


NetRange:       8.8.8.0 - 8.8.8.255
CIDR:           8.8.8.0/24
NetName:        GOGL
NetHandle:      NET-8-8-8-0-2
Parent:         NET8 (NET-8-0-0-0-0)
NetType:        Direct Allocation
OriginAS:
Organization:   Google LLC (GOGL)
RegDate:        2023-12-28
Updated:        2023-12-28
Ref:            https://rdap.arin.net/registry/ip/8.8.8.0



OrgName:        Google LLC
OrgId:          GOGL
Address:        1600 Amphitheatre Parkway
City:           Mountain View
StateProv:      CA
PostalCode:     94043
Country:        US
RegDate:        2000-03-30
Updated:        2019-10-31
Comment:        Please note that the recommended way to file abuse complaints are located in the following links.
Comment:
Comment:        To report abuse and illegal activity: https://www.google.com/contact/
Comment:
Comment:        For legal requests: http://support.google.com/legal
Comment:
Comment:        Regards,
Comment:        The Google Team
Ref:            https://rdap.arin.net/registry/entity/GOGL


OrgAbuseHandle: ABUSE5250-ARIN
OrgAbuseName:   Abuse
OrgAbusePhone:  +1-650-253-0000
OrgAbuseEmail:  network-abuse@google.com
OrgAbuseRef:    https://rdap.arin.net/registry/entity/ABUSE5250-ARIN

OrgTechHandle: ZG39-ARIN
OrgTechName:   Google LLC
OrgTechPhone:  +1-650-253-0000
OrgTechEmail:  arin-contact@google.com
OrgTechRef:    https://rdap.arin.net/registry/entity/ZG39-ARIN


#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/
#
# Copyright 1997-2025, American Registry for Internet Numbers, Ltd.
#
```
ARINのデータベースからの結果でした。Googleが用意しているものなので、Google LLCと表示されています。
もう一つの有名な、CloudflareのパブリックDNSである`1.1.1.1`も見てみましょう。
```bash
whois 1.1.1.1
```
```bash
% [whois.apnic.net]
% Whois data copyright terms    http://www.apnic.net/db/dbcopyright.html

% Information related to '1.1.1.0 - 1.1.1.255'

% Abuse contact for '1.1.1.0 - 1.1.1.255' is 'helpdesk@apnic.net'

inetnum:        1.1.1.0 - 1.1.1.255
netname:        APNIC-LABS
descr:          APNIC and Cloudflare DNS Resolver project
descr:          Routed globally by AS13335/Cloudflare
descr:          Research prefix for APNIC Labs
country:        AU
org:            ORG-ARAD1-AP
admin-c:        AIC3-AP
tech-c:         AIC3-AP
abuse-c:        AA1412-AP
status:         ASSIGNED PORTABLE
remarks:        ---------------
remarks:        All Cloudflare abuse reporting can be done via
remarks:        resolver-abuse@cloudflare.com
remarks:        ---------------
mnt-by:         APNIC-HM
mnt-routes:     MAINT-APNICRANDNET
mnt-irt:        IRT-APNICRANDNET-AU
last-modified:  2023-04-26T22:57:58Z
mnt-lower:      MAINT-APNICRANDNET
source:         APNIC

irt:            IRT-APNICRANDNET-AU
address:        PO Box 3646
address:        South Brisbane, QLD 4101
address:        Australia
e-mail:         helpdesk@apnic.net
abuse-mailbox:  helpdesk@apnic.net
admin-c:        AR302-AP
tech-c:         AR302-AP
auth:           # Filtered
remarks:        helpdesk@apnic.net was validated on 2021-02-09
mnt-by:         MAINT-AU-APNIC-GM85-AP
last-modified:  2021-03-09T01:10:21Z
source:         APNIC

organisation:   ORG-ARAD1-AP
org-name:       APNIC Research and Development
org-type:       LIR
country:        AU
address:        6 Cordelia St
phone:          +61-7-38583100
fax-no:         +61-7-38583199
e-mail:         helpdesk@apnic.net
mnt-ref:        APNIC-HM
mnt-by:         APNIC-HM
last-modified:  2023-09-05T02:15:19Z
source:         APNIC

role:           ABUSE APNICRANDNETAU
address:        PO Box 3646
address:        South Brisbane, QLD 4101
address:        Australia
country:        ZZ
phone:          +000000000
e-mail:         helpdesk@apnic.net
admin-c:        AR302-AP
tech-c:         AR302-AP
nic-hdl:        AA1412-AP
remarks:        Generated from irt object IRT-APNICRANDNET-AU
abuse-mailbox:  helpdesk@apnic.net
mnt-by:         APNIC-ABUSE
last-modified:  2021-03-09T01:10:22Z
source:         APNIC

role:           APNICRANDNET Infrastructure Contact
address:        6 Cordelia St
                South Brisbane
                QLD 4101
country:        AU
phone:          +61 7 3858 3100
e-mail:         research@apnic.net
admin-c:        AIC3-AP
tech-c:         AIC3-AP
nic-hdl:        AIC3-AP
mnt-by:         MAINT-APNICRANDNET
last-modified:  2024-07-18T04:37:37Z
source:         APNIC

% Information related to '1.1.1.0/24AS13335'

route:          1.1.1.0/24
origin:         AS13335
descr:          APNIC Research and Development
                6 Cordelia St
mnt-by:         MAINT-APNICRANDNET
last-modified:  2023-04-26T02:42:44Z
source:         APNIC

% This query was served by the APNIC Whois Service version 1.88.25 (WHOIS-JP3)
```

ちなみに、IPアドレスを指定すると表示される項目が変わります。また、`-h`オプションで問合せ先を変指定する事ができます。
```bash
whois -h whois.nic.ad.jp 131.112.1.1
```
```bash
[ JPNIC database provides information regarding IP address and ASN. Its use   ]
[ is restricted to network administration purposes. For further information,  ]
[ use 'whois -h whois.nic.ad.jp help'. To only display English output,        ]
[ add '/e' at the end of command, e.g. 'whois -h whois.nic.ad.jp xxx/e'.      ]

Network Information: [ネットワーク情報]
a. [IPネットワークアドレス]     131.112.0.0/16
b. [ネットワーク名]             STNET
f. [組織名]                     東京科学大学
g. [Organization]               Institute of Science Tokyo
m. [管理者連絡窓口]             JP00095425
n. [技術連絡担当者]             JP00095425
o. [Abuse]
p. [ネームサーバ]               ns.fujisawa.wide.ad.jp
p. [ネームサーバ]               ns1.noc.titech.ac.jp
p. [ネームサーバ]               ns2.noc.titech.ac.jp
[割当年月日]
[返却年月日]
[最終更新]                      2024/12/06 09:53:04(JST)

上位情報
----------
該当するデータがありません。

下位情報
----------
該当するデータがありません。
```
```bash
whois -h whois.apnic.net 131.112.1.1
```
```bash
% [whois.apnic.net]
% Whois data copyright terms    http://www.apnic.net/db/dbcopyright.html

% Information related to '131.112.0.0 - 131.112.255.255'

% Abuse contact for '131.112.0.0 - 131.112.255.255' is 'hostmaster@nic.ad.jp'

inetnum:        131.112.0.0 - 131.112.255.255
netname:        STNET
descr:          Institute of Science Tokyo
country:        JP
admin-c:        NOC2-AP
tech-c:         NOC2-AP
status:         ALLOCATED PORTABLE
mnt-by:         MAINT-JPNIC
mnt-irt:        IRT-JPNIC-JP
mnt-lower:      MAINT-JPNIC
last-modified:  2024-12-07T02:12:03Z
source:         APNIC

irt:            IRT-JPNIC-JP
address:        Uchikanda OS Bldg 4F, 2-12-6 Uchi-Kanda
address:        Chiyoda-ku, Tokyo 101-0047, japan
e-mail:         hostmaster@nic.ad.jp
abuse-mailbox:  hostmaster@nic.ad.jp
phone:          +81-3-5297-2311
fax-no:         +81-3-5297-2312
admin-c:        JNIC1-AP
tech-c:         JNIC1-AP
auth:           # Filtered
remarks:        hostmaster@nic.ad.jp was validated on 2024-11-27
mnt-by:         MAINT-JPNIC
last-modified:  2024-11-27T01:47:27Z
source:         APNIC

person:         Network Operation Center
address:        2-12-1, Ookayama
                Meguro-ku, 152-8550
country:        JP
phone:          +81 3 5734 3460
e-mail:         noc-staff@noc.titech.ac.jp
nic-hdl:        NOC2-AP
remarks:        ----------
remarks:        imported from ARIN object:
remarks:
remarks:        poc-handle:  ZT8-ARIN
remarks:        is-role:     Y
remarks:        last-name:   Network Operation Center
remarks:        street:      2-12-1, Ookayama
                Meguro-ku, 152-8550
remarks:        country:     JP
remarks:        mailbox:     noc-staff@noc.titech.ac.jp
remarks:        bus-phone:   81 3 5734 3460
remarks:        reg-date:    1999-12-09
remarks:        changed:     hostmaster@arin.poc 20020801
remarks:        source:      ARIN
remarks:
remarks:        ----------
notify:         noc-staff@noc.titech.ac.jp
mnt-by:         MNT-ERX-TOKYOINSTECH-NON-JP
last-modified:  2008-09-04T07:29:35Z
source:         APNIC

% This query was served by the APNIC Whois Service version 1.88.25 (WHOIS-JP3)
```

今回はwhoisコマンドを使って、いくつかのwhois情報を参照してみました。
色々調べてるだけでも面白いので、是非いろんなドメイン、IPで試してみてください。