Gentoo Wiki




Zeroconf provides a simple way to network several computers without DHCP/DNS servers. It is a set of techniques to assign an IP address, provide name resolution and service discovery. It is most useful for ad-hoc networks (LAN-Party, Meeting, WLAN, Bluetooth, etc).


In this HOWTO we'll use the Avahi implementation of the protocols. We'll set up automatic IP address configuration and name resolution.


The following packages are needed:

The following use flags should be set:


There is not much configuration needed but as the documentation is sparse you need to know where to look. First edit /etc/conf.d/net (replace eth0 with your interface):

File: /etc/conf.d/net
 modules=( "autoipd" )
 config_eth0=( "autoipd" )

If you want to try DHCP before getting an IP address with avahi use the following (useful for laptops in different environments):

 config_eth0=( "dhcp" )
 fallback_eth0=( "autoipd" )

If you use the second configuration you may want to reduce the timeout for the DHCP client. Therefore see /etc/dhcp/dhclient.conf.sample for dhclient.

sys-auth/nss-mdns provides functionality to hook into the name resolution process, so that zeroconf .local addresses are checked before using normal DNS. To enable .local name resolution, you need to edit the file /etc/nsswitch.conf:

File: /etc/nsswitch.conf

Change the following

 hosts:       files dns


 hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

or, if you also want IPv6 support, to

 hosts:          files mdns_minimal [NOTFOUND=return] dns mdns

Now add the relevant daemons to the runlevels:

  # rc-update add avahi-daemon default

Start Avahi

To immediately make use of Avahi do the following as root:

  # /etc/init.d/net.eth0 restart
  # /etc/init.d/avahi-daemon start

Now you should have a 169.254.* IP address (try ifconfig). Try to ping <yourhostname>.local to see if name resolution for the .local domain works.

Advertise Service

To advertise a service, create a file in /etc/avahi/services. For example, to advertise your http server, create file /etc/avahi/services/http.service with the following contents:

  <name replace-wildcards="yes">HTTP Server on %h.</name>

Scan for Services

To scan your network for advertised services, you can download mdns-scan from


This article is a bit short and could use some improvements:

Retrieved from ""

Last modified: Fri, 05 Sep 2008 09:46:00 +0000 Hits: 3,535