Most people never think about how two of their own devices reach each other, until they try to open a file on their home computer from a hotel, or share an app running on their laptop with a client. Then they meet port forwarding, dynamic IPs, router menus and firewalls, and it stops being simple.
Mesh networks are the modern answer to that problem. This guide comes in two parts. Part 1 explains how mesh networks work in general: what they are, why they beat the traditional hub-and-spoke VPN, and the building blocks every mesh needs. Part 2 shows how HostAnywhere builds each of those blocks: how a device signs in, how it finds a direct path through NAT, what happens when it can't, how access rules are enforced, and how a stranger's browser reaches an app on your laptop. Everything in Part 2 describes how the product actually works today, down to the ports and timers.
The short version
- A mesh network is a private network laid over the internet, where every device can connect straight to every other device instead of going through one central server.
- Every mesh needs five things: device identity (keys), a coordination server that tells devices about each other, NAT traversal to connect through home routers, relays for when that fails, and access control.
- In HostAnywhere, each device gets a private address and a WireGuard key pair whose private key never leaves the device. The control plane coordinates; it doesn't carry your traffic.
- Devices connect directly whenever the networks in between allow it, and through a relay when they don't. Every connection starts on the relay so it works immediately, then moves to the direct path once that's proven.
- Access rules are written once in the dashboard and enforced by each device's own firewall. Public URLs let anyone reach a web app on your device, with no open ports.
Part 1 · How mesh networks work
What is a mesh network?
The phrase gets used for two different things. Wi-Fi mesh systems, such as eero, Google Nest Wifi or TP-Link Deco, use several access points to spread one Wi-Fi network around a house. This guide is about the other kind: a mesh network of devices, sometimes called a mesh VPN or overlay network, that connects your computers, phones and servers wherever they are, as if they were all plugged into the same switch.
It's called an overlay because it sits on top of the networks you already use. Your laptop stays on café Wi-Fi and your server stays behind your home router; the mesh adds a private network across both. Each device gets a second, private address on that network, and each pair of devices that talk to each other does so through its own encrypted tunnel. Traffic between two devices takes the most direct path available: straight between them where the networks allow it, or through a relay when they don't. No single server sits in the middle of every connection; each device is a peer of every other.
Many modern mesh networks, HostAnywhere included, build those tunnels with WireGuard, a fast, small and well-audited encryption protocol built into Linux and available on every major platform.
Why your devices can't reach each other today
Your laptop and your home server are both on the internet, so why can't one simply connect to the other? Because almost no device on the internet has its own public address anymore.
Your home router has one public IP address and shares it among everything in the house using NAT (network address translation). When your laptop opens a website, the router rewrites the outgoing packet so it appears to come from the router, remembers the connection, and passes the reply back to the laptop. That works perfectly for connections your devices start. It fails for connections that start outside: when a packet arrives at the router that doesn't match anything a device asked for, the router has no idea which device it's for, so it drops it.
It gets worse. Many mobile carriers, and a growing number of home internet providers, put an extra layer of NAT in front of your router, called carrier-grade NAT (CGNAT). Your router doesn't even have a public address of its own; it shares one with hundreds of other customers. Port forwarding, the traditional fix, can't help you there, because the port you'd forward is on a router you don't control. Add café and hotel Wi-Fi that isolates clients, corporate firewalls that block anything that isn't web traffic, and IP addresses that change whenever the router restarts, and "just connect to my home server" turns out to be hard.
The way around all of this rests on one observation: outbound connections work almost everywhere. Mesh networks are built on that: every device only ever reaches out, and the pieces in the middle arrange for those outbound connections to meet.
Hub-and-spoke vs mesh
A traditional VPN is hub-and-spoke. Every device connects to one central server, the concentrator, and every packet goes through it, even when two devices sit in the same city or the same building. The hub becomes a bottleneck for speed, a single point of failure, and the one place where all traffic is visible.
A mesh removes the hub from the data path. Each device is configured with the keys of its peers, so traffic takes the shortest path between the two devices that are actually talking. A laptop and a NAS in the same house talk over the LAN; a laptop in a hotel and a server at home talk across the internet directly. A central service still coordinates who belongs to the network, but it doesn't carry the traffic, and a relay is used only for pairs of devices that can't reach each other directly.
The five building blocks of a mesh network
Connecting every device to every other sounds simple until you count. Five devices need 10 tunnels; twenty need 190; a hundred need 4,950. Each tunnel needs both ends to know the other's key and address, and those addresses change whenever someone moves between networks. Nobody can manage that by hand, so every practical mesh network is built from the same five pieces:
- Identity. Each device has its own cryptographic key pair. The public key is the device's identity on the network; the private key proves it, and never leaves the device.
- A coordination server. A central service, often called the control plane, that knows which devices belong together and tells each one about its peers: their public keys and how to reach them. It coordinates the mesh without sitting in the middle of it.
- NAT traversal. Most devices sit behind routers that block incoming connections. Techniques such as STUN, UDP hole punching and router port mapping let two devices behind different routers connect directly anyway.
- Relays. Some networks make a direct connection impossible. A relay is a server both devices can reach, which forwards traffic between them so the connection still works.
- Access control. A mesh where everything can reach everything is a flat network. Rules decide which devices and people can reach which services, and the best place to enforce them is on the devices themselves.
Part 2 walks through each of these as HostAnywhere implements them.
Part 2 · How HostAnywhere works
Adding a device: sign-in and SSO
Before a device can join your network, it has to prove which account it belongs to. HostAnywhere doesn't run its own password database for this. The agent opens a browser window, and you sign in with an identity you already have: Google, Microsoft, GitHub, Apple, a one-time email link, or your company's single sign-on.
Company SSO uses OpenID Connect, so it works with identity providers such as Okta, Microsoft Entra ID, Google Workspace, Auth0 and OneLogin. HostAnywhere recognizes your organization from your email domain and sends you to your company's login page, where your company's own rules apply: password policy, multi-factor authentication, conditional access. Your identity provider then sends you back to HostAnywhere with a one-time code, HostAnywhere exchanges it directly with the identity provider for a signed ID token, and reads your verified email address from that token. HostAnywhere never sees your company password.
Once you're verified, the control plane gives the agent a device credential, and the browser window's job is done. From then on the agent uses that credential, plus its WireGuard public key, to register and join your networks, as described in the next section. Phones sign in the same way.
Control plane and data plane
HostAnywhere has two halves, and keeping them apart is the most important idea in this guide.
- The control plane is the coordinator. It knows which devices belong to which networks, what address each one has, how to reach it, and what it's allowed to talk to. It's where your dashboard lives.
- The data plane is your actual traffic: the SSH session, the file copy, the video stream. It flows between your devices over encrypted WireGuard tunnels, either directly or through a relay. It never goes through the control plane.
When the agent starts on a device for the first time, it generates a WireGuard key pair: a private key and a matching public key. The private key is stored on that device and never sent anywhere. The agent registers with the control plane by sending only the public half, along with what it knows about how it can be reached:
- its public address and port as the internet sees them, which it learns using STUN (more on that below);
- a port its router opened for it, if the router supports NAT-PMP or UPnP;
- its local network address, so devices on the same LAN can connect without leaving the building.
In return, the control plane sends back the device's private address, the list of peers it should know about (each with a public key and endpoints), the relay to use as a fallback, and the access policy that applies to it. The device configures its WireGuard interface from that and starts connecting. Every 30 seconds it repeats the exchange, so new devices, changed addresses and edited rules spread through your network within about half a minute.
Splitting things this way has a practical benefit beyond security. If the control plane is unreachable for a while, connections that are already set up keep working, because the tunnels live on your devices, not on our servers. What pauses is change: a new device, an edited rule or a moved endpoint takes effect once the control plane is reachable again.
Every device gets a private address
Each device in a HostAnywhere network gets a stable private address from 100.64.0.0/10, a block reserved as shared address space (RFC 6598), so it won't collide with the 192.168.x.x and 10.x.x.x ranges used by home and office networks. Each network gets its own block inside that range, and a device keeps its address when it moves between Wi-Fi, Ethernet and cellular.
That address is what you use. ssh 100.64.13.9, http://100.64.13.9:8096 for a media server, a mapped drive, a remote desktop session: any app that can talk to an IP address works, with no plugin or special client. The same thing happens on every platform. Windows, macOS and Linux run the HostAnywhere agent; the iPhone and Android apps run the same WireGuard engine inside the phone's VPN slot.
Devices only learn about peers in networks they belong to. A device that isn't in your network isn't in your peer lists, so it has no key to talk to your devices with, even before any access rules apply.
Finding a direct path
The fastest connection between two devices is a direct one, with no server in between. Getting a direct WireGuard connection through two NATs is called NAT traversal, and HostAnywhere uses three techniques for it, all at once.
Learning how the internet sees you
A device behind NAT doesn't know its own public address and port, so HostAnywhere finds out in two ways. The agent asks a public STUN server, which replies with the public IP address the request came from. And because every device keeps a WireGuard connection to the relay from the same socket it uses for its peers, the relay sees the exact public address and port the router assigned to that socket, for example 203.0.113.7:41641. The control plane hands that observed endpoint to your other devices as the place to try.
The agent repeats the STUN check every 30 seconds, so when your laptop moves from home Wi-Fi to a hotspot, its new address reaches your other devices on the next sync instead of leaving them dialing a dead endpoint.
Hole punching: both devices knock at once
Knowing each other's public endpoint isn't enough on its own, because a NAT drops incoming packets it wasn't expecting. The trick is that every outgoing packet makes the sender's NAT expect a reply. When your laptop sends a WireGuard packet to the home server's public endpoint, the laptop's router creates a mapping for it and starts accepting packets coming back from that address: it has punched a hole for the server. The home server does the same in the other direction.
So both devices send to each other at the same time. The very first packet usually dies at the far router, because that side hasn't punched its hole yet. But a moment later both holes are open, the next packets get through in both directions, and the WireGuard handshake completes. Nothing has to be timed perfectly: WireGuard retries the handshake every few seconds, and once the path works, a keepalive every 25 seconds keeps both holes open.
Why it sometimes fails: how NATs map and filter
Whether hole punching works depends on two behaviors of each router, defined in RFC 4787, the IETF's description of how NATs should treat UDP.
Mapping is how the router picks the public address and port for a device's outgoing packets:
- Endpoint-independent mapping (EIM): the router reuses the same public address and port for a socket no matter where it sends. The endpoint the relay observed is then the same endpoint every other device can use. Most home routers behave this way, and RFC 4787 requires it.
- Endpoint-dependent mapping (RFC 4787's "address-dependent" and "address and port-dependent" mapping, often called symmetric NAT): the router picks a new public port for each destination. The port the relay saw is useless to your other devices, because packets to them leave from a different port. This is more common on carrier-grade NAT and corporate firewalls.
Filtering is which incoming packets the router lets through to a mapping:
- Endpoint-independent filtering (EIF): once a mapping exists, packets from any address are accepted. The device is effectively reachable as soon as it has sent anything.
- Endpoint-dependent filtering ("address-dependent" or "address and port-dependent" filtering): only packets from an address, or exact address and port, that the device has already sent to are accepted. This is what makes the simultaneous "knock" necessary.
Put together:
| Device A's router | Device B's router | Result |
|---|---|---|
| EIM, any filtering | EIM, any filtering | Direct. Both observed endpoints are correct, and simultaneous hole punching opens both filters. |
| EIM + EIF | Endpoint-dependent mapping | Usually direct. B's packets arrive from an unexpected port, but A's router accepts them, and WireGuard learns B's real port from the first valid packet. |
| EIM + endpoint-dependent filtering | Endpoint-dependent mapping | Relay. A's router only accepts the port A sent to, and B's packets come from a different one. |
| Endpoint-dependent mapping | Endpoint-dependent mapping | Relay. Neither side can predict the other's port. |
| Port mapping (NAT-PMP/UPnP) or a public IP | Anything | Usually direct. A has a fixed, reachable endpoint, so B only has to reach out. |
That last row is why the agent also asks the router for a port mapping, covered next. A firewall that blocks UDP outright prevents a direct path whatever the NAT does; that case is handled by the relay.
NAT-PMP and UPnP: asking the router to open a port
Many home routers will open a port if a device asks politely, using NAT-PMP or UPnP. The agent tries both. If the router agrees and the mapping is on a genuinely public address (not a carrier-grade NAT address), the agent reports it as its preferred endpoint and renews the mapping while it runs. This matters because only one side of a pair needs a reachable port for a direct connection to work: a laptop behind strict NAT can still connect directly to a home server whose router granted a mapping.
Same-LAN detection
Two devices in the same house shouldn't send traffic out to the internet and back. Each device reports its local address too, so peers on the same network connect over the LAN at full local speed.
Relay first, direct when proven
Here's the part most people never notice. When a device learns about a peer, it doesn't wait to find out whether the direct path works. Traffic starts on the relay immediately, so the connection works within a second or two. In the background, the device keeps trying the direct endpoints. As soon as a WireGuard handshake succeeds on a direct path, traffic moves to it. If that path later goes quiet (the laptop changed networks, the router dropped the mapping), traffic moves back to the relay after a few minutes without a handshake, and the device keeps probing for a new direct path. The trade-off is deliberate: a connection that works in the first second, at the cost of a slightly longer route until the direct path is confirmed.
When there's no direct path: the relay
Sometimes a direct path is impossible. If both devices are behind carrier-grade NAT, or one is behind a corporate firewall that changes ports on every connection, there's no address either side can reach. For those pairs, traffic goes through a HostAnywhere relay, and the connection still works; it just takes a slightly longer route.
The relay is a WireGuard server. Each device keeps an encrypted WireGuard tunnel to it, and when a packet is addressed to a peer that can't be reached directly, the device sends it down that tunnel. The relay forwards it to the destination over the destination's own encrypted tunnel. The relay also carries traffic for subnets that a device shares (see gateways below), so a LAN behind a VPN Gateway stays reachable even when the gateway device is only reachable through the relay.
Getting through networks that block UDP
WireGuard uses UDP, and some networks, especially corporate and public Wi-Fi, block or throttle UDP to unusual ports. The agent works around this with a fallback ladder:
- UDP port 51820, WireGuard's standard port. This works on almost every home and mobile network.
- UDP port 443. If no handshake gets through on 51820, the agent switches the relay connection to UDP 443, the port used by HTTP/3, which many restrictive networks allow.
- WireGuard inside a WebSocket over HTTPS. If UDP is blocked entirely, the agent carries the same WireGuard packets inside an ordinary HTTPS WebSocket connection. To the network it looks like normal web traffic, so it works on many networks that allow secure WebSockets, including some with TLS inspection, where an inspecting proxy that opens the HTTPS layer only sees WireGuard's encrypted packets inside. Networks that block WebSockets altogether, or require proxy authentication, can still prevent it.
Put together, here's what to expect in common situations. Real outcomes depend on how each router and firewall behaves.
| Network conditions | Connection |
|---|---|
| Both devices on the same LAN | Direct, over the LAN |
| One device's router grants a port mapping (NAT-PMP/UPnP) | Usually direct |
| Both behind ordinary home NAT | Often direct, via hole punching |
| Both behind CGNAT or strict corporate NAT | Relay |
| UDP blocked, secure WebSockets allowed | Relay over WebSocket/HTTPS |
| UDP and WebSockets both blocked | No connection |
None of this needs configuring. It's why the same laptop can connect from home, from a café and from inside a locked-down office without anyone touching a setting.
Access control: who can reach what
Being on the same network shouldn't mean everything can reach everything. HostAnywhere's access control lets you write rules in the dashboard, such as "engineers can reach the build servers on SSH" or "the contractor's laptop can reach this one web app and nothing else", and every device enforces them.
Rules match on devices or tags, direction, ports and protocol, and they're evaluated in priority order. Each network has a default policy: allow, where the network is open and rules carve out exceptions, or deny, where nothing is reachable unless a rule allows it. A rule can also carry posture conditions, so access depends on the connecting device's security state, for example whether it's managed and compliant in Microsoft Intune or healthy in CrowdStrike Falcon.
The important design choice is where rules are enforced. The control plane resolves your rules into a specific policy for each device and sends it with the 30-second sync. The device then enforces it with its own operating system's firewall:
- macOS: the built-in pf packet filter.
- Windows: Windows Defender Firewall rules scoped to the HostAnywhere adapter.
- Linux: iptables chains on the HostAnywhere interface.
- iPhone and Android: the app leaves blocked peers out of the phone's WireGuard configuration, so packets to them have nowhere to go. Phones enforce per device rather than per port; the desktop or server on the other end applies the finer-grained rules.
Enforcing on the device rather than at a central checkpoint means rules apply the same way whether traffic goes direct or through the relay, and there's no central box that every packet has to pass through. On desktops and servers, connections already in progress aren't cut off mid-stream when a rule changes; new connections follow the new policy.
Reaching whole networks and the internet: gateways
So far every device has run HostAnywhere itself. Two features extend the network beyond that.
VPN Gateway lets one device share the local network it sits on. You turn it on for, say, a Raspberry Pi at home and add the subnet it can reach, such as 192.168.1.0/24. Every other device in your network can then reach printers, NAS boxes, cameras and internal apps on that subnet, none of which need to run anything. Traffic travels to the gateway device over the private network (direct or relayed, as above), and the gateway passes it onto its LAN.
Internet Gateway works in the other direction: it sends a device's internet traffic out through another device you trust, such as a home server, a NAS or a cloud VPS. On café Wi-Fi, your laptop's browsing travels encrypted to your home connection and leaves from there, so websites see your home IP, and the café network sees only encrypted packets. You can set primary, secondary and tertiary gateways for automatic failover. We wrote more about this in using an exit node on coffee-shop Wi-Fi.
Public URLs: how a visitor reaches your laptop
Everything above is private: only your devices can use it. Public URLs solve the opposite problem: you have a web app running on your laptop or home server, and you want anyone with a browser to reach it, without opening a port.
The trick is the same as before: the device reaches out first. When you expose a service, the agent opens an outbound TLS connection on port 443 to a HostAnywhere relay. HostAnywhere runs relays in San Jose, Virginia and Hyderabad, and the agent measures the latency to each and picks the fastest. That one connection is multiplexed, so it can carry many visitor requests at the same time.
Your service gets an address like https://myapp-ha12.hostanywhere.io. When someone opens it:
- Their browser connects over HTTPS to Cloudflare's edge, which passes the request to a HostAnywhere relay.
- The relay looks up which agent holds the tunnel for
myapp-ha12. If that agent is connected to a different relay, the request is forwarded between relays over HostAnywhere's private links. - The request travels down the agent's existing outbound connection to your device.
- The agent hands it to your local app, for example
localhost:3000, and the response goes back the same way.
Because nothing listens on your public IP, there's no port to scan and no router setting to change, and it works behind carrier-grade NAT. The address stays the same every day, which matters for webhooks, demos and anything you've shared a link to. If your device is off, visitors see a clear "service offline" page instead of a timeout. Public URLs carry web traffic: HTTP, HTTPS and WebSockets. For raw TCP services like databases or game servers, use the private network instead.
Built on the same network: AI Server, AI Gateway and backups
The private network and the relays are foundations; HostAnywhere's other features are built on top of them.
- AI Server turns one of your own machines into a private AI server running open models. Your other devices reach it over the private network, and you can optionally put its web chat on a Public URL. See how to run your own AI server.
- AI Gateway gives you one OpenAI-compatible endpoint in front of your own AI Server and cloud providers, with routing, guardrails and spend limits. It runs on your device or fully hosted. When it's hosted, it reaches models and tools on your devices through a connection the device opens outward, the same pattern as Public URLs. The AI Gateway guide covers it in depth.
- Phone Backup backs up photos, contacts, calendars and more from your phone to a Storage Server on one of your own computers, traveling over the private network. Backups are encrypted on the phone before upload, and the encryption keys and your backup data are never held by the same party. The details are on our backup security page.
What HostAnywhere can and can't see
If you're deciding whether to trust a network product, this is the section that matters, so here it is without marketing.
- Private keys: created on each device and never sent to HostAnywhere. Without a device's private key, nobody can impersonate that device or join your network as it.
- What the control plane stores: your account, your networks and their members, each device's name, public key, private address and endpoints, your access rules and dashboard settings. That's what it needs to coordinate.
- Direct connections: go straight between your devices and never pass through HostAnywhere servers.
- Relayed connections: travel over encrypted WireGuard tunnels between each device and the relay, and are used only when no direct path is available.
- Public URLs: like any HTTPS reverse proxy, the edge and relay terminate HTTPS so they can route each request to the right tunnel. That's inherent to giving a local app a public web address.
Frequently asked questions
Is HostAnywhere a VPN?
It uses the same technology as a modern VPN, WireGuard, but it's arranged differently. A traditional VPN sends every device's traffic through one central server. HostAnywhere connects your devices to each other, directly wherever possible, and only sends traffic through a relay when there's no direct path. Your normal internet traffic isn't routed through HostAnywhere unless you turn on an Internet Gateway, and then it goes through a device you own.
Does it work behind CGNAT?
Yes. Carrier-grade NAT is one of the main reasons HostAnywhere exists. Devices behind CGNAT connect directly when the other side is reachable, and through the relay when it isn't. Public URLs also work behind CGNAT, because the agent makes an outbound connection.
Do I need to open any ports or change router settings?
No manual port forwarding is needed. The agent connects outbound first. If your router supports NAT-PMP or UPnP and allows it, the agent asks the router for a port mapping, which improves the chance of a direct connection; when there's no direct path, the relay is used instead. Public URLs never need an inbound port on your router.
Which devices does it run on?
Windows, macOS, Linux, iPhone and Android. All of them get a private address on the same network and follow the same access rules. See the download page.
What happens if HostAnywhere's servers are unreachable?
Existing direct connections keep working, because the tunnels are configured on your devices. Relayed connections depend on the relay being reachable. Changes such as new devices, edited rules or a device changing networks wait until the control plane is back.
How fast is it?
Direct connections run at whatever your two internet connections allow, with WireGuard's very small overhead. On the same LAN, you get local network speed. Relayed connections add the round trip to the relay, which is why the agent keeps looking for a direct path.
How much does it cost?
The free plan includes 3 users, 10 devices and 3 public services, with no credit card. Developer ($9/month) adds more devices and services plus VPN Gateway and Internet Gateway; Team ($25/month) adds SSO and more seats. See pricing.
Try it
Create a free account at hostanywhere.io, install the agent on two devices, and they'll find each other within a minute, directly if they can, through the relay if they can't. The docs walk through adding devices, exposing a service and writing your first access rule.