4

What would be the preferred way to make the raspberry pi respond to hostname.local?

For example on a raspberry pi which hostname is set to berry :

ssh pi@berry.local

This would be to make it available by name to all computers (Mac OS/linux) in the network. I would like it to work directly on all the similar networks I bring it to.

Coyote
  • 462
  • 1
  • 4
  • 14

5 Answers5

4

For berry.local to work, you need to either have avahi running, so that the name is resolved via mDNS, or your router must have appropriate host entries and a default local domain which is searched. The avahi approach is probably the least trouble, and is also needed if you want to use shairport or other zeroconf services.

Arne
  • 2,234
  • 2
  • 18
  • 35
3

avahi does this, and it's on by default on Raspbian.

If you're on Windows you need to install an external service to handle doing the lookups. Appe's Bonjour Print Services comes with mDNSResponser.exe, which works for this purpose (even though you're not using it for printing).

SoapBox
  • 130
  • 4
1

The best way of getting your Pi into the network DNS is going to depend on the details of the environment where you're trying to access it. There are several approaches:

  • As others have suggested, using avahi will allow the Pi to broadcast it's name and the services it offers to other systems. The advantage is, you can configure everything on the Pi. Disadvantage is, all the others systems on your network need to be running a compatible DNS system.
  • If there's only one other computer involved, you could add berry.local to the hosts file. (Or known_hosts, if applicable.)
  • If you have a router which supplies DNS to your network, you may also have the option of configuring the router to resolve the name.
ThatBlairGuy
  • 111
  • 3
0

You need an entry in ~/.ssh/known_hosts (on the machine you are running ssh)

Try logging on as:- https://raspberrypi.stackexchange.com/a/11853/8697

Milliways
  • 62,573
  • 32
  • 113
  • 225
0

To make this work on any network with any computer You need to use a real domain, sorry. But all the other solutions (Avahi/hostfile...) requires setup of the other machines.

I also like to connect to my machines on my network by name. So i have bought a domain-name (quite cheap now a days), and setup dyndns.

First Let me stress that just because the domain-name is available from the internet, this does NOT make your device available on the internet.

When my device boots up it gets a IP-number from the local DHCP server (usually build into the router/modem), this is standard behavior and this is probably how your raspbarry already works.

But i added a little script that sends a message to the name-server that host my domain-name (I use gratisdns.dk), with the new ip-address, and the DNS record is updated.

While you cannot use berry.local, but have to use something like berry.fancyname.eu, it still fulfills your purpose, also if you connect at another network.

The verbose version of the procedure:

  1. Berry powers on
  2. Berry request ip number on the network.
  3. Some DHCP server replies with a ip number
  4. Berry now has an address on the network usually 192.168.0.xxx
  5. Berry sends message to the name-server out there on the big internet.
  6. Name-sever updates its DNS record for berry.zzz.zz
  7. Some other computer (Conny) on the same network want to connect to berry
  8. Betty ask the DNS server for berry.zzz.zz (is it would if it connected to stackexchange.com)
  9. DNS relies the request out there on the net and replies with the ip-number of Berry.
  10. betty can now connect to berry.

So any computer on the same network as berry, that can connect to any website out there can now also connect to berry.

Otzen
  • 151
  • 2