# Self-Hosting Behind CGNAT

DevFeed: [Self-Hosting Behind CGNAT](<https://devfeed.tech/articles/self-hosting-behind-cgnat-60980.md>)

Original publisher: [Read original article](<https://david.alvarezrosa.com/posts/self-hosting-behind-cgnat/>)

Author: David Álvarez Rosa

Published: 2026-09-21T07:32:00Z

Content type: tutorial

Language: en

Sources: [David Álvarez Rosa](<https://devfeed.tech/sources/david-alvarez-rosa.md>)

Topics: [Homelab](<https://devfeed.tech/topics/homelab.md>), [Virtual Private Network](<https://devfeed.tech/topics/vpn.md>), [Self-hosted](<https://devfeed.tech/topics/self-hosted.md>), [NAT and SNAT](<https://devfeed.tech/topics/nat-and-snat.md>), [IP routing](<https://devfeed.tech/topics/ip-routing.md>)

Tags: [cgnat](<https://devfeed.tech/tags/cgnat.md>), [homelab](<https://devfeed.tech/tags/homelab.md>), [hosting](<https://devfeed.tech/tags/hosting.md>), [internet](<https://devfeed.tech/tags/internet.md>), [ipv4](<https://devfeed.tech/tags/ipv4.md>), [nat](<https://devfeed.tech/tags/nat.md>), [self-hosting](<https://devfeed.tech/tags/self-hosting.md>), [ssh](<https://devfeed.tech/tags/ssh.md>), [static](<https://devfeed.tech/tags/static.md>), [vps](<https://devfeed.tech/tags/vps.md>)

## AI overview

The article explains how to expose home-hosted services behind carrier-grade NAT by routing traffic through a VPS bridge over a bidirectional WireGuard tunnel. It describes the tunnel configuration, the added 39 ms round-trip-time penalty, and recovery options for failures.

## Source excerpt

There is nothing more satisfying than owning, end to end, the software and the hardware you use without relying on abusive cloud corporations. Internet is us, not them. Break free from censorship. Learn how to self-host at home, and be truly libre. In the past, self-hosting was easier. You just had to open a port on your router and forward it to any machine at home.1 Nowadays, the shortage of IPv4 addresses means routers share the same IP across your neighborhood. Requests are routed using carrier-grade NAT (CGNAT), a second-layer NAT inside the carrier's network, where your router's address is private and translated by the carrier on the way out. The public address is the carrier's, so port forwarding no longer works. Topology § My services run on a mid-range machine in my mother's basement in northern Spain, and are exposed to the Internet through a cheap VPS bridge in a French data center. +-------------------------------------+ | public Internet | +-------------------------------------+ ^ ^ | inbound | v | +------------+ | | bridge | | egress +------------+ | ^^ | || WireGuard | vv | +-------------------------------------+ | homelab | +-------------------------------------+ Code Snippet 1: Topology diagram. The homelab is exposed to the Internet through a WireGuard tunnel to a VPS bridge. A bidirectional WireGuard tunnel2 forwards all packets in all ports from the bridge to the homelab box, and vice versa. The beauty of this is that the tunnel is initiated by the homelab, so you don't need a static dedicated IP at home.3 The penalty of the bridge is 39 ms of RTT. Tunnel configuration § Bridge's wg0.conf.4 [Interface] Address = 10.0.0.1/24 PrivateKey = <bridge-private-key> ListenPort = 51820 PostUp = ... PostDown = ... [Peer] PublicKey = <homelab-public-key> AllowedIPs = 10.0.0.2/32 PostUp sets up NAT and forwarding rules at the kernel level.5 The first two exclude ports 2222 for SSH, and 51820 for the VPN tunnel itself. The last three forward all traffic in all