Cross-VLAN Google Cast implementation
1. Problem statement¶
YouTube/Google Cast (Chromecast) relies on device discovery via mDNS (UDP 5353, multicast 224.0.0.251) and, as a fallback path for some apps, SSDP/DIAL (UDP 1900, multicast 239.255.255.250). These are multicast protocols, and multicast does not cross subnet/VLAN boundaries by default — even though ordinary unicast IP routing between the VLANs already works fine. Result: a phone on VLAN A cannot discover a Chromecast on VLAN B, even though the two can otherwise reach each other.
2. Hardware / environment specification¶
| Item | Value |
|---|---|
| Router | MikroTik RB951Ui-2HnD |
| CPU architecture | mipsbe |
| RouterOS version | v6.47.8 (stable) |
| Router resources | 128 MB RAM, 128 MB storage, single 600 MHz MIPS core |
| VLAN setup | Two (or more) VLANs on this MikroTik, already routed at Layer 3 |
| Available server | Same physical machine that also runs the existing k3s cluster |
| Server NIC count | To be confirmed — check physical back panel for number of RJ45 Ethernet ports, and whether any are currently unused |
Hardware constraint: no container support on this router¶
RouterOS v7 adds container support, which could in theory run an mDNS reflector directly on the router — but only on ARM, ARM64, or x86 (CHR) architectures. The RB951Ui-2HnD is mipsbe, so containers are permanently unavailable on this board regardless of RouterOS version, and its 128 MB of storage is too small for a realistic container runtime anyway. Upgrading firmware alone does not unlock this feature on this hardware. An OS upgrade may still be worth doing for general stability/security, but not for this specific reason.
3. Core concept¶
Reflecting multicast traffic requires a device with live network presence on every VLAN that needs to discover each other, so it can receive a multicast packet on one VLAN and re-emit it on the others. The MikroTik already has all the VLANs but cannot run the reflector software (see constraint above). The reflector must therefore run on a separate device — in this case, the existing server — that has (or is given) a network leg into each relevant VLAN.
4. Decisions already made¶
Reflector software: avahi-daemon, running in reflector mode, handles mDNS. It may need to be paired with a lightweight SSDP proxy/bridge if SSDP/DIAL discovery paths aren't sufficiently covered by mDNS reflection alone (test first; add only if needed).
Where it runs: on the existing server — the same physical machine that already runs k3s. No new hardware purchase is required.
How it runs: as a native OS-level service (e.g. a systemd unit), installed directly on the host operating system — not as a Kubernetes pod/deployment inside the k3s cluster. This was a deliberate choice: a Kubernetes pod sits behind k3s's own pod network (Flannel/Calico overlay), which does not expose the host's real VLANs without extra plumbing (hostNetwork or Multus/macvlan), and its uptime would then be tied to k3s's own restarts, upgrades, and pod scheduling. Running it as a plain host service avoids all of that — it behaves like any other system service (e.g. sshd), independent of anything happening inside the cluster on that same box.
Why not new hardware instead: a new ARM-based MikroTik with RouterOS v7 + a container, or a new router/AP with a built-in mDNS gateway (UniFi/Aruba/Cisco), would both work equally well from a pure effectiveness standpoint — none of the three approaches is "the compromised option," they use the identical underlying reflection mechanism. The existing-server approach is recommended purely because it needs no new hardware purchase and carries the least risk to already-working infrastructure. The hardware-replacement routes are only worth it if there's an independent reason to upgrade router or Wi-Fi/switching equipment anyway.
5. Open item — confirm before proceeding¶
How many physical Ethernet (RJ45) ports does the server have, and is a second one free?
- If a second, unused NIC is available: simplest path — plug it into an access port on the other VLAN, assign a static IP in that subnet, no trunking/VLAN-tagging needed at all.
- If only one NIC is available: the MikroTik switch port feeding this server needs to become an 802.1Q trunk carrying all relevant VLAN IDs tagged, and the server OS creates one tagged VLAN sub-interface per VLAN to separate the traffic in software.
This single answer determines which variant of Step 2 (below) to follow.
6. Step-by-step implementation¶
-
Check current network interfaces. SSH into the server and run:
Confirms existing NICs/IPs and whether a second port is free (see Section 5). -
Get a network leg into each relevant VLAN.
Option A — dedicated NIC per VLAN (if a spare RJ45 port is available): plug the second NIC into an access port on the other VLAN and assign it a static IP in that subnet. No further network config needed.
Option B — trunk with tagged VLAN sub-interfaces (if only one NIC is available): change the MikroTik switch port feeding this server from access to trunk, tagging the relevant VLAN IDs. Then create tagged sub-interfaces on the host — example using netplan:
network:
vlans:
eth0.10:
id: 10
link: eth0
addresses: [<SERVER_VLAN_A_IP>/24]
eth0.20:
id: 20
link: eth0
addresses: [<SERVER_VLAN_B_IP>/24]
netplan apply (substitute actual VLAN IDs/subnets, and adjust syntax if the host doesn't use netplan).
-
Install avahi-daemon:
(adjust for the host's actual distro/package manager if not Debian/Ubuntu-based) -
Enable reflector mode. Edit
List whichever interface names were actually created/used in Step 2./etc/avahi/avahi-daemon.conf: -
Restart and enable on boot:
-
Check the MikroTik firewall. In
/ip firewall filter, confirm the forward chain allows traffic between the VLAN subnets that should discover each other (some default/wizard configs drop inter-VLAN traffic by default). -
Optional: enable IGMP proxy (
/routing igmp-proxy, available in v6.47.8) between the relevant VLAN interfaces. This may help SSDP-based discovery as a complement to avahi, but will not reliably fix mDNS on its own — mDNS packets are typically sent with IP TTL=1 by design (RFC 6762) and are dropped before most routers' multicast-routing logic even applies, so this step is a free bonus attempt, not a substitute for the reflector. -
Test discovery. From a Linux/Mac device on one VLAN:
Confirm services advertised on the other VLAN(s) are visible. -
Test real casting. Attempt an actual YouTube/Chromecast cast session between devices on different VLANs, end to end.
-
Confirm persistence. Reboot the server (or restart networking) and re-run the discovery test, to confirm the VLAN interfaces and avahi-daemon both come back up correctly without manual intervention.
7. Scaling to more than 2 VLANs¶
If casting needs to span more than two VLANs, the same architecture holds, scaled up:
- The server needs a network leg (NIC or tagged sub-interface) into every VLAN involved — N VLANs means N interfaces, e.g.
eth0.10,eth0.20,eth0.30, etc. - List every one of those interfaces in avahi's
allow-interfaces— the reflector logic itself handles any number of interfaces, not just a pair. - On the MikroTik, firewall/IGMP-proxy rules need to explicitly permit traffic between whichever VLAN pairs should reach each other — this becomes an N×N decision (all-to-all vs. specific pairs only) rather than a single pairwise rule as VLAN count grows.
8. Background reference¶
mDNS vs. SSDP — what they are and how they differ¶
mDNS (Multicast DNS) performs DNS-style name/service resolution over the local network via multicast, rather than a central DNS server. Runs on UDP 5353, multicasting to 224.0.0.251 (IPv4) / ff02::fb (IPv6), using standard DNS record types (A, PTR, SRV, TXT). It's the basis of Apple's Bonjour and is what Google Cast uses to advertise itself as _googlecast._tcp.local.
SSDP (Simple Service Discovery Protocol) is the discovery component of UPnP. Runs on UDP 1900, multicasting to 239.255.255.250. Devices send NOTIFY messages or respond to M-SEARCH queries, pointing to an XML description fetched over plain HTTP. Google's DIAL protocol (used to find and launch an app on a Chromecast) is built on top of SSDP for its initial discovery step.
Both are multicast-based, which is why both are blocked the same way at a VLAN boundary. Google Cast leans primarily on mDNS, with SSDP/DIAL as a fallback/parallel path for some apps — a complete fix reflects both.
Full cast session lifecycle¶
- Device self-announcement — the Chromecast periodically multicasts mDNS announcements (
_googlecast._tcp.local) on boot and thereafter; listening devices can passively cache this. - Active discovery query — opening the Cast picker sends a fresh mDNS query rather than relying on a cached announcement; the Chromecast responds directly (unicast) to the asking device. Both the query and reply are multicast-scoped and are exactly what the reflector relays across VLANs.
- (Fallback) SSDP/DIAL discovery — some apps instead send an SSDP M-SEARCH; the Chromecast replies with a location URL, fetched via plain HTTP.
- Connection establishment — the phone opens a direct unicast TCP connection to the Chromecast (historically port 8009, CastV2 over TLS). Ordinary unicast — already routed fine by the MikroTik once firewall rules allow it.
- App launch request — the phone tells the Chromecast which receiver app to start (e.g. the YouTube receiver).
- Session negotiation — sender/receiver establish a session ID over CastV2.
- Media load command — the phone sends the video URL/ID and playback parameters.
- Independent media fetch — the Chromecast fetches the video directly from YouTube's servers; the phone becomes a remote control, not a relay.
- Playback/control channel — the unicast connection stays open for play/pause/seek/volume/status sync.
- Session teardown — on stop, STOP is sent, the receiver app shuts down, the connection closes, and the Chromecast resumes periodic mDNS self-announcement.
Practical implication: only steps 1–3 (discovery) are multicast and need the reflector; everything from step 4 onward is unicast and already works once routing/firewall permits it. This applies to Google Cast broadly (YouTube, Netflix, mirroring, etc.), not just YouTube specifically.
Other approaches considered (for completeness)¶
| Approach | Verdict |
|---|---|
| Enterprise AP/switch with built-in mDNS gateway (UniFi, Aruba AirGroup, Cisco Wide Area Bonjour) | Fully effective, but requires new hardware/ecosystem — not usable with current equipment without a purchase |
| IGMP proxy on MikroTik alone | Free, worth enabling, but unlikely to fully fix mDNS specifically due to TTL=1 scoping — treat as a bonus, not a full solution |
| Merge cast-relevant devices onto one shared VLAN | Fully effective, avoids the multicast-routing problem entirely, at the cost of reduced segmentation for those specific devices |
| Cloud-based casting via shared Google account (bypasses LAN discovery) | Unreliable/inconsistent across apps — not something to plan around |
| Commercial mDNS gateway appliance | Fully effective, functionally identical to the avahi approach, just as a paid packaged product instead of self-managed |
| New ARM-based MikroTik on RouterOS v7 + avahi container | Fully effective, but means new router hardware and a config migration |
| avahi-daemon as native OS service on existing server (recommended) | Fully effective, no new hardware, lowest operational risk |
9. Remaining open items¶
- Confirm server's physical NIC count and whether a second port is free (Section 5) — determines Option A vs. Option B in Step 2.
- Confirm server's OS/distro, to finalize exact package-manager and network-config syntax (guide assumes Debian/Ubuntu with netplan).
- Once both above are confirmed: finalize exact MikroTik trunk/firewall commands and the final
avahi-daemon.conf.