コマンド一つでかんたんにできます!
コマンドを実行するために必要なソフトのインストール
sudo apt-get install dnsutils
インストール時の様子
sudo apt-get install dnsutils Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: bind9-host libbind9-90 libdns100 libisc95 libisccfg90 liblwres90 Suggested packages: rblcheck The following NEW packages will be installed: dnsutils The following packages will be upgraded: bind9-host libbind9-90 libdns100 libisc95 libisccfg90 liblwres90 6 upgraded, 1 newly installed, 0 to remove and 143 not upgraded. Need to get 1,063 kB of archives. After this operation, 326 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main bind9-host armhf 1:9.9.5.dfsg-9+deb8u5 [65.1 kB] Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main libisc95 armhf 1:9.9.5.dfsg-9+deb8u5 [149 kB] Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main libdns100 armhf 1:9.9.5.dfsg-9+deb8u5 [598 kB] Get:4 http://mirrordirector.raspbian.org/raspbian/ jessie/main libisccfg90 armhf 1:9.9.5.dfsg-9+deb8u5 [49.8 kB] Get:5 http://mirrordirector.raspbian.org/raspbian/ jessie/main libbind9-90 armhf 1:9.9.5.dfsg-9+deb8u5 [40.7 kB] Get:6 http://mirrordirector.raspbian.org/raspbian/ jessie/main liblwres90 armhf 1:9.9.5.dfsg-9+deb8u5 [47.3 kB] Get:7 http://mirrordirector.raspbian.org/raspbian/ jessie/main dnsutils armhf 1:9.9.5.dfsg-9+deb8u5 [113 kB] Fetched 1,063 kB in 3s (343 kB/s) (Reading database ... 149326 files and directories currently installed.) Preparing to unpack .../bind9-host_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking bind9-host (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Preparing to unpack .../libisc95_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking libisc95 (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Preparing to unpack .../libdns100_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking libdns100 (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Preparing to unpack .../libisccfg90_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking libisccfg90 (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Preparing to unpack .../libbind9-90_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking libbind9-90 (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Preparing to unpack .../liblwres90_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking liblwres90 (1:9.9.5.dfsg-9+deb8u5) over (1:9.9.5.dfsg-9+deb8u3) ... Selecting previously unselected package dnsutils. Preparing to unpack .../dnsutils_1%3a9.9.5.dfsg-9+deb8u5_armhf.deb ... Unpacking dnsutils (1:9.9.5.dfsg-9+deb8u5) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up libisc95 (1:9.9.5.dfsg-9+deb8u5) ... Setting up libdns100 (1:9.9.5.dfsg-9+deb8u5) ... Setting up libisccfg90 (1:9.9.5.dfsg-9+deb8u5) ... Setting up libbind9-90 (1:9.9.5.dfsg-9+deb8u5) ... Setting up liblwres90 (1:9.9.5.dfsg-9+deb8u5) ... Setting up bind9-host (1:9.9.5.dfsg-9+deb8u5) ... Setting up dnsutils (1:9.9.5.dfsg-9+deb8u5) ... Processing triggers for libc-bin (2.19-18+deb8u1) ...
使い方の例
dig google.co.jp
実行例
pi@raspberrypi:~ $ dig www.google.co.jp ; <<>> DiG 9.9.5-9+deb8u5-Raspbian <<>> www.google.co.jp ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17293 ;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1280 ;; QUESTION SECTION: ;www.google.co.jp. IN A ;; ANSWER SECTION: www.google.co.jp. 61 IN A 202.224.62.104 www.google.co.jp. 61 IN A 202.224.62.113 www.google.co.jp. 61 IN A 202.224.62.84 www.google.co.jp. 61 IN A 202.224.62.93 www.google.co.jp. 61 IN A 202.224.62.123 www.google.co.jp. 61 IN A 202.224.62.109 www.google.co.jp. 61 IN A 202.224.62.103 www.google.co.jp. 61 IN A 202.224.62.114 www.google.co.jp. 61 IN A 202.224.62.94 www.google.co.jp. 61 IN A 202.224.62.98 www.google.co.jp. 61 IN A 202.224.62.88 www.google.co.jp. 61 IN A 202.224.62.89 www.google.co.jp. 61 IN A 202.224.62.108 www.google.co.jp. 61 IN A 202.224.62.118 www.google.co.jp. 61 IN A 202.224.62.99 www.google.co.jp. 61 IN A 202.224.62.119 ;; Query time: 26 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Wed Feb 10 04:01:37 UTC 2016 ;; MSG SIZE rcvd: 301
解説
digはドメイン名(例だとgoogle.co.jp)をDNSサーバに問い合わせ、その結果が表示されています。
上の例だとgoogle.co.jpは202.224.62.104など、多くのIPアドレスと対応付けされていることがわかります。
結果の見方を説明するととても複雑になるので、興味のある方は「DNSサーバ」というキーワードで検索してみるといいかと思います!
ラズベリーパイでネットワークの状態を確認したい時にすごく便利です!