English
简体中文繁體中文EnglishРусскийفارسی

Home › Blog › Home

A house without a number

No public IPv4 at home? Check for CGNAT, connect over IPv6, relay through a VPS with WireGuard, or use a tool that punches holes.

Compiled on

One building, hundreds of homes, one address
One building, hundreds of homes, one address PattayaPatrol, CC BY-SA 4.0

WireGuard needs at least one side that can be found. With both home and phone inside the carrier's network, nobody can knock first.

Many home lines installed since 2020 share an address. The router says the port forward worked, but there is another router above it at the provider that you cannot reach.

Make sure

If the router's WAN address differs from a what-is-my-IP page, or starts between 100.64 and 100.127, there is no public IPv4.

A row of apartment mailboxes: no public IP is like a building with no street number
A row of apartment mailboxes: no public IP is like a building with no street number Marek Ślusarczyk (Tupungato) Photo portfolio, CC BY 3.0

Four ways

  1. Ask the carrierSome hand out a public IPv4 on request
  2. Use IPv6If both sides have it, open the UDP port and connect directly
  3. Relay through a VPSBoth connect to the VPS, which passes it on
  4. Hole punchingTailscale, ZeroTier or NetBird find a path for you
From easy to laborious

The VPS relay

Home and phone are both peers of the VPS. What matters is AllowedIPs on the VPS:

wg0.conf on the VPS
[Peer]
# home
PublicKey = HOME_PUBLIC_KEY
AllowedIPs = 10.8.0.2/32, 192.168.1.0/24

[Peer]
# phone
PublicKey = PHONE_PUBLIC_KEY
AllowedIPs = 10.8.0.3/32

Add PersistentKeepalive = 25 at home to hold the door open and turn on forwarding on the VPS. The phone uses 10.8.0.0/24, 192.168.1.0/24.

A house number: IPv6 or a VPS gives you an address others can find
A house number: IPv6 or a VPS gives you an address others can find Tuodvinao TK, CC BY-SA 4.0

What each costs

WaySpeedMoney
IPv6 directYour home upload0
VPS relayThe slowest of the VPS and both linesA few dollars a month
Hole punchingDirect if it works, relayed if notMostly free tiers

Three minutes to find out

  1. Read the WAN IPv4 address in the router.
  2. Open any "what is my IP" page on the same network.
  3. Equal means public; different means not.
WAN address starts withMeaning
10., 172.16 to 172.31, 192.168.Another router above
100.64. to 100.127.Provider's shared address
Anything else, equal to the pagePublic

If the modem dials and the router only gets 192.168.1.x, look in the modem or have it set to bridge mode.

Direct over IPv6

Many providers and most mobile networks have IPv6. Test on the phone with Wi-Fi off, and at home; both need it.

  1. Turn on IPv6 in the routerDevices get an address starting with 2 or 3
  2. Open the firewallUDP 51820 to that machine
  3. Dynamic DNSAn AAAA record
  4. A fixed suffixNo temporary address
At home

An address in Endpoint needs brackets: [2001:db8::1]:51820. The name is resolved only once, when the tunnel starts: if the home address changes, switch the tunnel off and on. Networks with only IPv4, such as some offices and hotels, cannot use it; many people keep a VPS as the second way.

Relay through a VPS

Turn on forwarding:

VPS
echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-wg.conf
sudo sysctl --system
wg0.conf at home
[Interface]
Address = 10.8.0.2/32
PrivateKey = home-private-key

[Peer]
PublicKey = vps-public-key
Endpoint = vps-address:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25

To reach other devices at home, such as a NAS at 192.168.1.10, turn on forwarding there too and rewrite addresses, so that the NAS knows how to answer:

At home, adapter name as yours
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

What limits the speed

Home upload first, often a tenth of the download; then the VPS's bandwidth; then the distance, twice. Fine for managing and documents, not for 4K.

Why hole punching sometimes fails

Both NATs have to cooperate. If both use a different port per destination, only a relay is left; mobile networks are often like that. Try Tailscale first: a few tailscale ping tell whether direct works.

Is direct IPv6 unsafe?

Open only WireGuard's UDP port. It does not answer anyone without a key.

My IPv6 changes.

Use dynamic DNS as with IPv4, updating the address of the WireGuard machine, not the router.

How do I ask for a public IP?

Say you have cameras at home and need access from outside. Some give it, some change the plan, some refuse.

Are all devices exposed with IPv6?

The router's IPv6 firewall blocks incoming by default; you open one port. Do not turn it off.

Can the VPS read my traffic?

Yes, the two tunnels meet there. If that matters, build another tunnel inside, or use an end-to-end tool.

Next letter

On the same round

Postcodes: WireGuard without public IP, WireGuard CGNAT, WireGuard VPS relay