13
4

More than 3 years have passed since last update.

ラズベリーパイにIPアドレスではなくraspberrypi.localでアクセスできる理由

Posted at

DNSサーバーなどはつくっていないのになぜかラズベリーパイに

  • 名前でSSHできたり
ssh pi@raspberrypi.local
  • ウェブサーバー立ててブラウザからhttp://raspberrypi.local/ でアクセスしてindex.html 見れたりしたのですが、ずっと不思議でした。

しばらく調べて行って原因がわかりました。
mDNSという方法を使っています。
確認のために以下を打つとこの機能が動いているのがわかります。

sudo /etc/init.d/avahi-daemon status

試しに、

sudo /etc/init.d/avahi-daemon stop

をやると名前でアクセスできなくなるのを試すことができます。

つまり、avahi-daemonというものを使って、名前をつけたいサーバーで設定するだけで名前解決できるのですごく便利です。(もちろん、同一のネットワーク内でしか有効ではないです。)
社内サーバーを作る時とかには有効ですね。

参考:

IPアドレスがわからないラズパイにホスト名でSSH接続する簡単な方法(mDNS) | IoT PLUS
https://iot-plus.net/make/raspi/ssh-connect-using-mdns/

手持ちのRaspberryPiをサクッとmDNSに対応させる - Qiita
https://qiita.com/takish/items/1a640576caa2d0dfefc4

13
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
4