Skip to content

Instantly share code, notes, and snippets.

@jakelee8
Last active July 12, 2016 06:52
Show Gist options
  • Save jakelee8/2f19a1023ebd1d6ac74ce292fa7d40de to your computer and use it in GitHub Desktop.
Save jakelee8/2f19a1023ebd1d6ac74ce292fa7d40de to your computer and use it in GitHub Desktop.
Avahi Zeroconf for Linux

Avahi Zeroconf for Linux

Install

apt install avahi-utils avahi-daemon

The service starts automatically.

Services

Services are configured by placing .service files under /etc/avahi/services. The following service files publish their respective services. Additional service types are defined in DNS SRV (RFC 2782).

SSH service

File: /etc/avahi/services/ssh.service

<?xml version="1.0" standalone="no"?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>   
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_ssh._tcp</type>
    <port>22</port>
  </service>
</service-group>

SFTP service

File: /etc/avahi/services/sftp.service

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>   
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_sftp-ssh._tcp</type>
    <port>22</port>
  </service>
</service-group>

Restart Avahi

While Avahi will pick up the new configurations automatically, it's a good idea to restart the daemon to reset the state.

service avahi-daemon restart

Now the service should show up when browsing.

avahi-browse -a

Hostname resolution

To resolve local Zeroconf hostnames, e.g. foobar.local, add mdns_minimal [NOTFOUND=return] to the hosts configuration line of /etc/nsswitch.conf.

# /etc/nsswitch.conf

hosts: files mdns_minimal [NOTFOUND=return] dns

https://wiki.debian.org/ZeroConf https://wiki.archlinux.org/index.php/Avahi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment