wg-quick rule bypasses [Was: Re: Announcement: Public Wireguard server for testing]

Jason A. Donenfeld Jason at zx2c4.com
Sun Feb 26 19:28:41 CET 2017


Hey Jorg,

Moving this to a new thread.

On Sun, Feb 26, 2017 at 7:25 PM, Jörg Thalheim <joerg at thalheim.io> wrote:
> In this context, I found the following rules useful to bypass the vpn for some routes:
>
> #!/usr/bin/env bash
> # /etc/wireguard/<profile>.sh
>
> if [ "${1:-down}" = "up" ]; then
>   action="add"
> else
>   action="del"
> fi
>
> ip rule $action priority 32763 to 192.168.0.0/16 lookup main
> ip rule $action priority 32763 to 172.16.0.0/12 lookup main
> ip rule $action priority 32763 to 10.0.0.0/8 lookup main
> ip -6 rule $action priority 32763 to fd::/8 lookup main
> ip -6 rule $action priority 32763 to 2000::/3 unreachable
>
> #/etc/wireguard/<profile>.conf
>
> [Interface]
>
> #....
>
> PostUp=/etc/wireguard/<profile>.sh up
> PostDown=/etc/wireguard/<profile>.sh down

If any of those routes are already explicitly listed on the main
routing table (more specific than a /0 match), then this will already
happen. This is due to wg-quick's use of suppress_prefix 0.

Jaosn


More information about the WireGuard mailing list