Route certain clients through other gateway?

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

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?
 

eibgrad

Very Senior Member
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:

eibgrad

Very Senior Member
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 ...).
 

Latest threads

Sign Up For SNBForums Daily Digest

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