Skip to content

Instantly share code, notes, and snippets.

@steffenba
Created February 8, 2026 12:28
Show Gist options
  • Select an option

  • Save steffenba/2dc78f47bcb17ab0fd5c615d97578fb5 to your computer and use it in GitHub Desktop.

Select an option

Save steffenba/2dc78f47bcb17ab0fd5c615d97578fb5 to your computer and use it in GitHub Desktop.
Route only Public/Not Rerserved nets through wireguard

Preface

Because google is exceptionally useless at letting me find this information, I want to preserve this here.

I want to route everything through my wireguard tunnel, except all private networks and any reserved IPs. Depending on your usecase, you may want to extend or reduce the list.

Basically, my wireguard "server" (peer from the side of my client PC) should only route anything that goes to the internet, anything else goes via my local routes.

To do this, you need to enter the following info in the Wireguard allowed IPs calculator:

AllowedIPs

0.0.0.0/0

DisallowedIPs

  • It is important to add the public IP of your WG Server here!

<PUBLIC_IP_OF_YOUR_WG_SERVER>/32,[List of reserved IP Blocks you do NOT want to route through WG, see wikipedia]

Important

The resulting AllowedIPs does not contain your WG Network, if you add private networks to Disallowed IPs. To route anything to and through your server, you have to add your VPN Subnet to AllowedIPs

In the end, Allowed IPs should contain All Public Subnets, except your WG Server's Public IP Subnet (basically it will generate subnets "around" your Server's public IP/Subnet) and include your Wireguard VPN Subnet or just the VPN IP of your Wireguard server (which is a private ip).

The List of AllowedIPs goes into the [Peer] section on the client side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment