Skip to content

Instantly share code, notes, and snippets.

@xarinatan
Last active April 20, 2024 08:41
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xarinatan/c415341ff34eab445cfb073988dcf6c1 to your computer and use it in GitHub Desktop.
Save xarinatan/c415341ff34eab445cfb073988dcf6c1 to your computer and use it in GitHub Desktop.
How to set up PulseAudio over Network

How to set up PulseAudio over Network

PulseAudio actually has great networking capabilities. Especially when combined with Avahi/Zeroconf it is especially easy to set up, though technically it should also be possible without.

Setting up the server

  • Open /etc/pulseaudio/default.pa
  • At the end of the file, add load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.254.0/24 auth-anonymous=1 to activate networked audio from 192.168.254.0-255 without needing authentication.
  • Kill pulseaudio, it should be auto-restarted, or restart your login session to activate the changes. You should now be able to set PULSE_SERVER=192.168.254.XXX and have the remote audio working! If not check the firewall settings, PulseAudio seems to open a random port by default.

Setting up automatic configuration and discovery

  • On both the server and client, install pulseaudio-module-zeroconf and avahi, then after installing make sure Avahi always runs by running systemctl enable --now avahi-daemon
  • On the server in /etc/pulseaudio/default.pa , add load-module module-zeroconf-publish
  • On the client in /etc/pulseaudio/default.pa , add load-module module-zeroconf-discover
  • Restart pulseaudio and avahi if needed. The remote speakers should now show up in volume control applets like that of KDE, Gnome, or pavucontrol and be selectable for output.

Securing the setup to not allow anonymous logins

  • On the server in /etc/pulseaudio/default.pa , remove the auth-anonymous=1 from the end of the load module line we added.
  • copy the ~/.config/pulse/cookie file to all other devices you want to use the remote audio on
  • in paprefs if you have used it, uncheck 'don't require authentication'.
  • It should now only be available to devices with the cookie available

Sources

@creeper6530
Copy link

creeper6530 commented Dec 22, 2023

Works as a charm, thanks! Just a small note: You shouldn't kill PA server, rather than restart it by systemctl --user restart pulseaudio (without sudo).

@BachoSeven
Copy link

BachoSeven commented Jan 2, 2024

Do you know how to make this work when using pipewire-pulse?

Edit: this helped

https://forums.gentoo.org/viewtopic-p-8805291.html?sid=226eef1af0b51d19c2605dbd2ff20a93

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