What's new

Route certain clients through other gateway?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ajp2k14

Regular Contributor
I have a Raspberry Pi 4B setup as a Wireguard client gateway, is there a simple way to route certain clients through this gateway without changing the default gw on the clients?
 
Changing the default gateway of clients you want routed through WG *is* the way you typically achieve such results. I'm not sure what other options you are expecting. I suppose it is possible to create your own PBR (policy based routing) instead, similar to what the GUI provides for OpenVPN. But it may be more hassle than it's worth. It certainly isn't simpler than changing the clients' default gateway (which can be done through DNSMasq (dhcp) on a per-client basis).
 
Last edited:
P.S. It's also possible to override the default gateway on the client itself and have it point to the WG device. For example, using Windows ...

Code:
# change Windows routing table to a different default gateway
set VPN_GW="192.168.1.2"

route add 0.0.0.0 mask 128.0.0.0 %VPN_GW%
route add 128.0.0.0 mask 128.0.0.0 %VPN_GW%

Code:
# change Windows routing table back to original (ISP) default gateway
set VPN_GW="192.168.1.2"

route delete 0.0.0.0 mask 128.0.0.0 %VPN_GW%
route delete 128.0.0.0 mask 128.0.0.0 %VPN_GW%

NOTE: Using Windows 7 or better, you'll need elevated privileges to execute these commands (right-click Command Prompt, Run as administrator). Also, the route command is NOT permanent (i.e., it will revert on a reboot) unless you add the -p option (route -p ...).
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top