Gentoo Wiki ArchivesGentoo Wiki

HOWTO_Zeroconf

Contents

Introduction

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).

Summary

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

Requirements

The following packages are needed:

The following use flags should be set:

Configuration

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

to

 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:

<service-group>
  <name replace-wildcards="yes">HTTP Server on %h.</name>
  <service>
    <type>_http._tcp</type>
    <port>80</port>
  </service>
</service-group>

Scan for Services

To scan your network for advertised services, you can download mdns-scan from http://0pointer.de/lennart/projects/mdns-scan/.

TODO

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

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Zeroconf"

Last modified: Fri, 05 Sep 2008 19:46:00 +1000 Hits: 7,690

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.