Setting up Sonos on different subnets or VLANs

  • 21 December 2017
  • 11 replies

You might find this handy, if you have a linux box that handles connectivity between subnets...

This relays the multicast SSDP packets that the app uses to locate the speakers between interfaces and allows discovery to function even if your telephone happens to be on a different network than your speakers. Share and enjoy!

This topic has been closed for further comments. You can use the search bar to find a similar topic, or create a new one by clicking Create Topic at the top of the page.

11 replies

Userlevel 7
Badge +21
This might be a more desirable solution over a more all-inclusive IGMP proxy, which will take any multicast traffic from one network and send it to another, since yours is targeted just at SSDP/UPnP traffic on port 1900.

There are some various Linux and BSD-based router/firewall systems out there... if they support creating packages for add-ons, you might want to look into creating a package for this. Some may already have an IGMP Proxy functionality included, but again, yours is a lot more targeted in what it will send between networks.
I did first consider igmpproxy, only I'm already using it to get IPTV from my provider over to a TV box... and as igmpproxy only allows one single upstream interface to be specified, it was out of the question to try and get it to work for my Sonos setup.

Moreover, linux only allows one multicast router to be running at once so I couldn't even start a second igmpproxy nor consider smcrouted.

I'll see if I can get this contributed into the likes of when I have a bit more time to spend on it...
alsmith, I am trying to use your code. I have set up a VM with an interface listening on each VLAN. I see packeta being relayed between the subnets but I cannot get the controller app on one subnet to reach the Sonos speakers on the other.

Hear is a screenshot. Any ideas for troubleshooting?

Sonos discovery works via multicast which seems to working ok - the reply is unicast from the speaker(s) back to the controlling phone. If you're running it as a VM, have you enabled IP forwarding between interfaces?

Try this: echo 1 > /proc/sys/net/ipv4/ip_forward

Another thing to check is if you have any iptables filtering that might prevent your speakers' IP addresses from being able to establish a connection back to your phone's IP address.

Hope this helps you out ! Let me know if you still can't make it work.

F[General]I the latest version of also works for mDNS that is used by Chromecast.
Thanks for your help. It ended up being a firewall rule between the subnets blocking the unicast connection.

It's all working good now. Thanks again.
Splendid! Good to hear that you have it working!
Hey Al,
Do you mind supplying some more details on how to use it, as I'm not that kinda of a pro user?
Would it be enough to place the script on the subnet (on a raspy) where the Sonos boxes are?
How do I run it? -> [-h] --interfaces INTERFACE INTERFACE [INTERFACE ...] [--relay MULTICAST:PORT [MULTICAST:PORT ...]] [--noMDNS] [--noSSDP] [--wait] [--foreground] [--verbose]
INTERFACE is or is it eth0?

Thanks, would appreciate a bit more details!
Btw you know EyeTV, there seems to be the same 'issue', maybe your script could fix that too?
Hi User367999,

Unfortunately it's not enough to have run just on a box that's on the same subnet as your Sonos speakers, you would ideally need to run it on the system that routes between your subnets.

In my case I have a linux box that has several interfaces, one for wired hosts, one for WPA2-Enterprise EAP-TLS hosts (almost all of my wifi devices) and one for a WPA2-Personal network which is where things like a wifi printer, chromecast, and of course the sonos speakers all live.

Because the linux box is the device that routes packets between the various networks, that's where you'd have to run I do it like this, where br0 is my wired network, br2 is my WPA2-Enterprise network and br3 is my WPA2-PSK network:

./ --interfaces br0 br2 br3

Actually, it might be enough to have a raspberry that doesn't actually do routing, but where it's also connected to your multiple networks at once - I haven't tested it out but the way that multicast works it might well suffice if your device that is actually doing your routing isn't something that you can run the multicast relay on.

The relay would probably also work for EyeTV if it uses UPnP or mDNS for its discovery...

Update - multicast-relay now works on OpenWRT boxes too...
Userlevel 6
Badge +15
I'm curious if I could set this up on my Unifi router.
I'm curious if I could set this up on my Unifi router.

Probably... prerequisites are python and (ideally) netifaces, but you might be able to get away with using the --homebrewNetifaces flag - there are additional instructions in the file. Unfortunately I don't have a Unifi device that I could use for testing...