52

My Raspberry Pi is not discoverable via its hostname in my LAN.

I have a couple of other Ubuntu machines in the LAN, and they are all pingable via their hostnames.

On my Raspberry Pi:

pi@raspberrypi ~ $ hostname
raspberrypi

On another machine in the same LAN:

ping raspberrypi
ping: unknown host raspberrypi
Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
clamp
  • 829
  • 2
  • 12
  • 19

2 Answers2

81

You have to use avahi-daemon (zeroconf) if you want to connect via a hostname instead of an IP address. From the Raspberry Pi documentation on RPi Advanced Setup:

Install avahi with the following commands on the Raspberry Pi:

sudo apt-get install avahi-daemon

Update boot startup for avahi-daemon

sudo insserv avahi-daemon

Apply the new configuration with:

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

The Raspberry Pi should now be addressable from other machines as raspberrypi.local, for example: ssh pi@raspberrypi.local or http://raspberrypi.local if you have HTTP service installed.

If you couldn't connect from Windows PCs via SSH probably you haven't installed the Bonjour service.

Get Bonjour for Windows: Download Bonjour Print Services for Windows v2.0.2. Just install it.

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
gurcanozturk
  • 3,748
  • 1
  • 21
  • 17
19

Have you tried doing a ping test using the IP address? If that works your problem is usually with resolving the name to an IP address.

There are many ways to fix this. You could

  • Add an entry to your /etc/hosts file with your pi's static-ip and hostname
  • Add a static reservation to your dhcp server and add a record to your local dns server (If your router supports it)
  • Run a service like NIS, Avahi or Samba on your pi. The choice depends on the OS you are pinging from.
    • Windows clients will benefit from installing Samba.
    • OS/X clients will benefit from Avahi or Samba.
    • Linux clients will probably benefit from NIS or Samba depending on what is installed. I guess the Ubuntu computers use samba to advertise their hostnames.