the ‘auth-ip-acl=127.0.0.1’ parameter needs to use the IP from the WSL instance though (‘ip a’ on the WSL command line to get it)
(unfortunately the WSL IP change after a reboot so the config needs to be re-edited…)
start bin/pulseaudio
Disable Windows Defender Firewall for Guest or public Network (a better way would be to add firewall rules to allow only what is needed but I didn’t figure out how to do that yet, help welcome if anyone knows?)
Re the ‘auth-ip-acl=127.0.0.1’ parameter needs to use the IP from the WSL instance though.
I have edited my default.pa file to include acl auth-ip-acl=172.16.0.0/12 because WSL2 seems to choose any random address from this range. The only issue with this is that you may get other machines behind your router trying to send pulseaudio sound packets to your computer???
For me work the configurations as described above, but with a change:
in pulseaudio configuration in the file default.pa the line is
load-module module-native-protocol-tcp auth-anonymous=1
works fine on windows 10 build 2004 / wsl2 / ubuntu 20.4
Changes in WSL2 made my configuration stop working, too. I had to add the following to my ~/.bashrc file to make it work again:
# Get the IP Address of the Windows 10 Host and use it in Environment.
HOST_IP=$(host `hostname` | grep -oP '(\s)\d+(\.\d+){3}' | tail -1 | awk '{ print $NF }' | tr -d '\r')
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$HOST_IP:0.0
export NO_AT_BRIDGE=1
export PULSE_SERVER=tcp:$HOST_IP
After doing that, any BASH prompt should enable sound, regardless of your Host IP address or WSL IP address. You’ll use similar in command lines in shortcuts to Linux GUI programs to get sound to work with various programs, as needed. Below is a screenshot of Linux and Windows programs working together, while watching a video on YouTube, using Google-Chrome on Linux in WSL.
It was kind of tricky... well, I only got to make it work out by:
using this specific line in the pulseaudio\etc\pulse\default.pa @ Windows: ( load-module module-native-protocol-tcp auth-anonymous=1 )
I'm a little bit worried about my security, but it's just cool to use Rhythmbox as my music player, so I think I'll give it a try until WSLg is out (commented in the end). Can anyone explain us how dangerous it is?
and by appending these lines to my ~/.bashrc @ Ubuntu: (
You can already try it out - the WSLg (WSL GUI), if you are inscribed into the Windows Insider program.
It's really hard to fully leave Windows, some commercial softwares are just too good. As a gamer and graphic softwares user, I got stuck here... My mom, my dad and one of my sisters, who rarely touch bash/terminal are full Ubuntu users... LOL
so that it includes both rfc1918 networks. This is more secure than allowing anonymous, but could still potentially allow anyone on one of these IPs to play or record audio from your windows host.