WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Howto: Resolve local hostnames using avahi  (Read 12673 times)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Howto: Resolve local hostnames using avahi
« on: June 11, 2011, 03:56:30 AM »
If your router doesn't resolve local hostnames and you don't want to use dnsmasq, read on:

1. Load avahi-2.7 and start the avahi daemon.

2. Modify /etc/nsswitch as follows:
Code: [Select]
hosts:      files [before]
hosts:      files mdns4_minimal [NOTFOUND=return] dns mdns4 [after]

3. [Due to a bug in avahi]:
Code: [Select]
$ sudo ln -s /var/run/avahi-daemon/* /usr/local/var/run/avahi-daemon
..and now, by adding .local to the hostname, you can ping devices on the local network using their hostname rather than their ip address.

Note that in same cases, avahi will find hostnames of devices that seem to be missed by dnsmasq, eg:
Code: [Select]
$ avahi-resolve -a 192.168.1.107
192.168.1.107   juanitos-iPhone.local

$ ping -c1 juanitos-iPhone.local
PING juanitos-iPhone.local (192.168.1.107): 56 data bytes
64 bytes from 192.168.1.107: seq=1 ttl=64 time=27.342 ms

Edit: I thought this would require multicast to be enabled in the kernel, but that doesn't appear to be neccessary
« Last Edit: June 11, 2011, 04:01:04 AM by Juanito »