How-to set up network audio server based on PulseAudio and auto-discovered via Avahi

Today i played with my cubietruck and wanted to make network audio server. I just open laptop, connect to WiFi, choose remote sound device in gnome-control-center and listen music.

First of all I’d want to say many thanks to Jonas Wielicki for help with debugging problems and providing his ansible playbook with the same task, Stefan Majewsky who inspired Jonas about configuration management and to Felipe Sateler for tip with permissions.

Server configuration

I have installed minimal Fedora so it means that I don’t have avahi, pulseaudio and other tools in system. Let’s install them:

# dnf install pulseaudio pulseaudio-module-zeroconf avahi

Nothing needs to be set up in avahi, so just start and enable daemon:

# systemctl start avahi-daemon
# systemctl enable avahi-daemon

module-native-protocol-tcp will use 4317/tcp port to handle connections, need to open port.

# firewall-cmd --add-port=4317/tcp
# firewall-cmd --add-port=4317/tcp --permanent

Unfortunately, firewalld currently doesn’t xml with service defined to just use --add-service=pulseaudio, but I already sent PATCH.

Time to configure PulseAudio. Add following lines to end of the /etc/pulse/

load-module module-native-protocol-tcp auth-ip-acl=; auth-anonymous=1
load-module module-zeroconf-publish

Since 6.0 PA socket-activated so we need to write systemd unit. Also running PA from root is not good, so we will use systemd user-session.

[Unit] avahi-daemon.service
Description=PulseAudio Sound System

ExecStart=/usr/bin/pulseaudio -vv
ExecStop=/usr/bin/pulseaudio --kill


Now we need to create user and add it to audio group.

# useradd -m -G audio media -s /bin/bash

All is ready. Login as media user and start and enable pulseaudio.service, but don’t try this. It will not work due to SELinux policy issues.
Create with following content:

module pulseaudio_user 1.0;

require {
        type proc_net_t;
        type avahi_t;
        type pulseaudio_t;
        class dbus send_msg;
        class file read;

#============= avahi_t ==============
allow avahi_t pulseaudio_t:dbus send_msg;

#============= pulseaudio_t ==============
allow pulseaudio_t avahi_t:dbus send_msg;
allow pulseaudio_t proc_net_t:file read;

Then compile and install it (requires policycoreutils-python package):

# checkmodule -M -m -o pulseaudio_user.mod pulseaudio_user.te
# semodule_package -o pulseaudio_user.pp -m pulseaudio_user.mod
# semodule -i pulseaudio_user.pp

Now we really can login as media user and enable PulseAudio:

$ systemctl --user enable pulseaudio.service

We also need to enable lingering for this user to start systemd user-session in boot time, not when user logins.

# loginctl enable-linger media

If you are getting Failed to get D-Bus connection: Connection refused:

$ export XDG_RUNTIME_DIR=/run/user/$(id -u)

Client configuration

On client you also need to have pulseaudio-module-zeroconf package. Simply add following line to the end of /etc/pulse/

load-module module-zeroconf-discover

Restart pulseaudio and gnome-control-center, pavucontrol will find our server.

gnome-control-center PA zeroconf

In case if you don’t want to use avahi, you can specify server manually for sink, something like:

$ pactl load-module module-tunnel-sink "server= sink=alsa_output.platform-1c22c00.codec.analog-stereo sink_name=cubietruck"

PulseAudio & Avahi & systemd –> Ready for Desktop

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments are closed.

  1. Julian Andres Klode says:

    Is it working well for you? Last time I tried it, it was quite choppy. There were interruptions every few minutes.

  2. konstantinjch says:

    1.Create with following content: = Create pulseaudio_user.te with following content:

    2.# loginctl enable-lingering media = # loginctl enable-linger media