How to route only specific IPs through Wireguard VPN

If you have a Wireguard VPN installed as specified here and want to only route specific traffic through it while the rest goes directly from your computer, you need to make some changes to your WireguardClient.conf file.

The examples below use the target IP address 1.2.3.4. Change it for your own target IP. You have two ways to accomplish this:

Option 1

  1. In the [Interface] section remove or comment the DNS directive
  2. In the [Peer] section, change the values for AllowedIPs to your target IP:
AllowedIPs = 1.2.3.4/32

… where 1.2.3.4 would be your target IP.

Option 2

  1. Copy the IPs listed in the [Interface] / DNS directive
  2. In the [Peer] section, change the values for AllowedIPs to your target IP and the IPs of the DNSs copied before while adding a /32 to the end of each IP.
AllowedIPs = 8.8.4.4/32, 8.8.8.8/32, 1.2.3.4/32

As you can see, all the IPs listed in the two options above end with a /32. These are CIDR ranges. Use this calculator for help.

Hope this helps.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *