Strategy2 min read
VLAN segmentation in WebRTC transfers: isolating a P2P service by design

In short
A local WebRTC transfer service groups devices by shared public IP. How to modify its signaling logic to restrict discovery between corporate VLANs.
PairDrop (a modern fork of Snapdrop) is one of the simplest ways to share files on local networks: it uses WebRTC directly between browsers, encrypts end to end and stores no data on any intermediate server.
It does have a design limitation on corporate networks with several VLANs, however: it groups peers by the client’s public IP.
If a network has two subnets isolated by a firewall — for example, a finance VLAN and an operations VLAN — both reach the internet through the router’s same public IP. To the signaling server, a computer in one department and a phone in another have the same apparent origin, so it shows them as visible to each other. This defeats network segmentation at the user level.
The design principle: group by private /24 prefix
Without spinning up separate instances on different ports, the server’s core signaling file is modified:
// Standard logic: groups by public remote IP
function getRoomId(req) {
return req.headers['x-forwarded-for'] || req.socket.remoteAddress;
}
It is changed to check whether the remote IP belongs to a corporate private block. Behind a reverse proxy configured to propagate the client’s real IP, the container receives the real local IP:
function getRoomId(req) {
const rawIp = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
// If the IP is private (RFC 1918) in the corporate range:
if (isCorporatePrivateRange(rawIp)) {
// Extract the first three octets (/24)
return rawIp.split('.').slice(0, 3).join('.');
}
return rawIp;
}
Why this strategy beats running separate instances
- Resource efficiency: a single container serves the whole organization on one port.
- Transparency for the user: everyone opens the same internal domain and sees their department colleagues, without creating rooms or manual passwords.
- Zero visibility between departments: a computer in one area has no way to discover clients in another VLAN, following the principle of least privilege.
Collaborations
Projects, research or ideas worth building together.