alsmith / multicast-relay

Relay multicast and broadcast packets between interfaces.
GNU General Public License v3.0
304 stars 47 forks source link

Can this be used on interfaces without MAC address? #10

Closed dynek closed 5 years ago

dynek commented 5 years ago

Hey,

First of all thanks for the code! I see a mac address is required for this code to run. Is it really required by the protocol itself, cause I wanted to give it a try through wireguard and the interface doesn't have a MAC address.

Thank you

alsmith commented 5 years ago

An interesting question - the rationale for finding out our relay interfaces' MAC addresses is that we tell the system that we want to get either broadcast IP packets or multicast IP packets from a particular multicast address. Thus we receive IPv4 frames from our listening sockets and not ethernet frames - of course if we received ethernet frames then we could extract the sender's MAC and just re-use it on the transmitting side of things.

If I understand it you'd like to use a VPN to relay multicast frames (and of course your VPN interface doesn't have the notion of a MAC address) - you're wanting to run the relay on a system that has one wireless interface (where your Sonos speakers are, presumably) - does is the other end of the VPN appear on your mobile device? I wonder if it would work to detect a VPN interface and instead of emitting ethernet frames out on that interface, to emit a different type of frame that the VPN would understand and want to relay.

dynek commented 5 years ago

Not sure what to answer :-)

But yes I'd like to be able to control sonos' speakers via a (wireguard) VPN.

alsmith commented 5 years ago

The Sonos app doesn't want to send discovery packets over a VPN - it only wants to discover via Wifi.

Is your use-case something like this?

iPhone[SonosApp] - wifi1 - VPNclient -----internet----- VPNserver - wifi2 - SonosSpeakers

Or this:

iPhone[SonosApp + VPNApp] ----- 4G ----- VPNserver - wifi2 - SonosSpeakers

dynek commented 5 years ago

Yeah I know but if you are connected to WiFi and run WireGuard, 239.255.255.250/32 can be routed through the tunnel and the sonos app is somehow tricked. I can see the SSDP frames reach the other end of the tunnel:

Android[SonosApp + WiFi (for nothing) + VPN] ----- internet ----- VPNserver

alsmith commented 5 years ago

Got it. Let's see if this helps you out... https://github.com/alsmith/multicast-relay/tree/vpn

dynek commented 5 years ago

OK the app starts and I can see the frames going through. They are relayed to my router which does PIM but so far it doesn't work. I'm checking it. Thanks!

alsmith commented 5 years ago

Hi @dynek - how are you getting on?

If we're able to confirm that Sonos' packets are at least reaching your PIM then I'll merge the experimental code to master.

dynek commented 5 years ago

Hey @alsmith - I still haven't found a way to get all of this work with my setup @home but I can confirm my main router does receive the UDP frames from the VPN server on which multicast-relay is running. Thank you!