If you are able to access the router over SSH, you can set a PostUp command in the interface config file (usually /etc/wireguard/wg0.conf

You can edit the file using nano: nano /etc/wireguard/wg0.conf

you should see something like this:

[Interface]
Address = 192.168.11.0/24
Address = xxxx::1/xx
PrivateKey = lonGsTringOfRandomcHars

[Peer]
…other stuff

You want to add two lines at the bottom of the [Interface] section, like so:

[Interface]
Address = 192.168.11.0/24
Address = xxxx::1/xx
PrivateKey = lonGsTringOfRandomcHars
PostUp = ip route add 192.168.11.0/24 dev wg0
PostDown = ip route del 192.168.11.0/24 dev wg0

[Peer]
…other stuff

Save the file by pressing ctrl^s, then exit using ctrl^x. From now on, wg will automatically add your static route when the interface is activated, and automatically remove it when the interface is disabled

cheers bru

1 Like