hn.today

Self-Hosting Behind Cgnat

david.alvarezrosa.com11 points4 comments
Screenshot of Self-Hosting Behind Cgnat

This explains how to self-host services from a home network that sits behind carrier-grade NAT (CGNAT), which blocks traditional router port forwarding by sharing a public IP across many customers. The solution is to run a cheap VPS as a public bridge and establish a bidirectional WireGuard tunnel initiated from the homelab to that bridge. That tunnel forwards all inbound ports from the VPS to the homelab while leaving the homelab-initiated traffic on the home router. The claimed benefits are end-to-end control of hardware and software, avoidance of cloud providers, and preserved client IP visibility because the bridge rewrites destinations but not sources. The setup adds about 39 ms RTT compared with a direct public IP, and a static ISP IP is noted as an alternative at roughly €20/month.

Technical specifics cover both endpoints: the bridge uses wg0 with Address=10.0.0.1/24, ListenPort=51820 and iptables rules that DNAT all non-exempt traffic to 10.0.0.2 while exempting UDP 51820 and TCP 2222; FORWARD rules accept the tunnel traffic. The homelab runs wg0 with Address=10.0.0.2/24, AllowedIPs=0.0.0.0/0, PersistentKeepalive=25 and policy-routing (ip route add default dev wg0 table 200; ip rule add from 10.0.0.2 table 200) so replies traverse the tunnel. Resilience strategies include a homelab cron that reboots if SSH fails, fallback access via Cloudflare Tunnel or Tailscale, and WireGuard’s rehandshake for short drops.

Read on david.alvarezrosa.com4 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Security

Type Punning in C and C++

Type Punning in C and C++

Type punning involves interpreting memory as different types, which is common in low-level programming but can lead to undefined behavior. In C, unions and memcpy are safe methods, while pointer casts are unsafe and violate strict aliasing rules, especially in C++ where the compiler assumes types do not alias. (blog.pwkf.org)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.