6

Is it possible to disable default gateway in WireGuard VPN client? I used "allowed IP" to my own subnet, but still whenever I try to connect to VPN server, the client sets default gateway to the WireGuard server IP.

Any other way to disable default gateway in WireGuard?

Dave M
  • 4,514
  • 22
  • 31
  • 30
Farhan
  • 4,269
  • 11
  • 49
  • 80

3 Answers3

4

Instead of specifying AllowedIPs = 0.0.0.0/0 specify an ip address.

Ran into this question wondering the same thing. The use case detailed here pointed me in the right direction: https://emanuelduss.ch/2018/09/wireguard-vpn-road-warrior-setup/

2

I used systemd. Setting netdev here https://www.freedesktop.org/software/systemd/man/systemd.netdev.html#%5BWireGuard%5D%20Section%20Options will not create route table entry for you. You'll need to manually add it here https://www.freedesktop.org/software/systemd/man/systemd.network.html#%5BNetwork%5D%20Section%20Options . I'm allowing all IPs but only route specific traffic to wg interface.

If using wg-quick, probably you'll need to change Table=off , per https://manpages.debian.org/unstable/wireguard-tools/wg-quick.8.en.html

Edit:

As systemd v250 https://github.com/systemd/systemd/releases , systemd will automatically creates routing for you. To disable so, you need to add RouteTable=off under [WireGuardPeer] in your netdev file.

mlyy
  • 21
  • 3
1

Old thread, but in case this can be of any help:

This simple solution seem to have worked fine for me (albeit I haven't tried actually routing anything other than a simple ping test through tun0 yet). Simply add ' Table = off' under [interfaces] in the config file.

Reference: https://shibumi.dev/posts/disable-routing-for-wireguard/

user993168
  • 11
  • 1