Understanding Avahi Daemon Errors: D-Bus Connection Failures and NSS Warnings in CentOS 5.2


2 views

Those messages from your CentOS 5.2 VPS reveal several important points about Avahi's operation:

Aug 28 11:57:52 echo avahi-daemon[21633]: WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
Aug 28 11:57:52 echo avahi-daemon[21633]: dbus_bus_get(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Avahi is essentially Linux's implementation of Zeroconf (Zero Configuration Networking), providing:

  • mDNS (Multicast DNS) service discovery - .local domain resolution
  • DNS-SD (DNS Service Discovery) - for advertising/discovering services
  • Link-local IPv4 addressing via IPv4LL

The specific errors in your log indicate:

# Missing D-Bus configuration
sudo /etc/init.d/messagebus start
# Or for CentOS 5:
sudo service messagebus start

# Missing NSS module for mDNS
sudo yum install nss-mdns

When working with Avahi in applications, you might interact with it through:

/* Simple service registration example */
#include <avahi-client/client.h>
#include <avahi-client/publish.h>

static AvahiEntryGroup *group = NULL;

void create_service(AvahiClient *c) {
    char *name = "My Web Service";
    char *type = "_http._tcp";
    uint16_t port = 8080;
    
    if (!group)
        group = avahi_entry_group_new(c, NULL, NULL);
        
    avahi_entry_group_add_service(group, 
        AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0,
        name, type, NULL, NULL, port, NULL);
        
    avahi_entry_group_commit(group);
}

Essential troubleshooting commands:

# Check Avahi status
avahi-browse -a

# Test mDNS resolution
avahi-resolve -n hostname.local

# Verbose daemon output (for debugging)
avahi-daemon -D -f /etc/avahi/avahi-daemon.conf

Notice these lines in your logs:

Found user 'avahi' (UID 70) and group 'avahi' (GID 70).
Successfully dropped root privileges.

This shows Avahi follows security best practices by:

  • Running as unprivileged user after initialization
  • Using dedicated system user/group (UID/GID 70)
  • Limiting potential attack surface

Avahi is a free Zero-configuration networking (zeroconf) implementation that allows devices to automatically discover services on a local network without requiring manual configuration. It's essentially Linux's implementation of Apple's Bonjour protocol, using mDNS (Multicast DNS) and DNS-SD (DNS Service Discovery).

Key functions of Avahi include:

  • Hostname resolution via mDNS (.local domain)
  • Service discovery for printers, file shares, etc.
  • IPv4 and IPv6 link-local address compatibility

The log messages you're seeing indicate several important events during avahi-daemon startup:

Aug 28 11:57:52 echo avahi-daemon[21633]: Found user 'avahi' (UID 70) and group 'avahi' (GID 70).
Aug 28 11:57:52 echo avahi-daemon[21633]: Successfully dropped root privileges.
Aug 28 11:57:52 echo avahi-daemon[21633]: avahi-daemon 0.6.16 starting up.
Aug 28 11:57:52 echo avahi-daemon[21633]: WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
Aug 28 11:57:52 echo avahi-daemon[21633]: dbus_bus_get(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Aug 28 11:57:52 echo avahi-daemon[21633]: WARNING: Failed to contact D-Bus daemon.

1. Missing D-Bus Dependency

The error about DBUS socket indicates the message bus system isn't running. To fix:

# For CentOS 5.2
sudo /etc/init.d/messagebus start
sudo chkconfig messagebus on

# Verify DBUS is running
ps aux | grep dbus

2. NSS Support for mDNS

The nss-mdns warning suggests name service switch functionality is missing. Install it with:

sudo yum install nss-mdns

Then edit /etc/nsswitch.conf to add mdns support:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

For VPS environments where service discovery isn't needed, you might consider disabling Avahi entirely:

sudo /etc/init.d/avahi-daemon stop
sudo chkconfig avahi-daemon off

If you do need Avahi, ensure proper configuration in /etc/avahi/avahi-daemon.conf:

[server]
host-name=yourhostname
domain-name=local
enable-dbus=yes

To get more detailed information about Avahi operations:

sudo avahi-daemon --debug

For testing service discovery:

avahi-browse -a -t