[Solved] WireGuard not adding static route

I configured WireGuard with one peer:

config interface 'wg0'
        option proto 'wireguard'
        option private_key 'xxxxxxxx'
        option listen_port '46422'
        list addresses ''

config wireguard_wg0
        option description 'la05'
        option public_key 'xxxxxxxx'
        list allowed_ips ''
        option endpoint_host 'example.com'
        option endpoint_port '38917'

I did not select the "No Host Routes" option

I confirmed the config has been loaded:

interface: wg0
  public key: xxxxx
  private key: (hidden)
  listening port: 46422

peer: xxxxx
  endpoint: xxx.xxx.xxx.xxx:38917
  allowed ips:

I expected this to create a static route for (like wg-quick on Linux does), but it didn't:

root@OpenWrt:~# ip -4 route
default via 135.180.xxx.xxx dev eth1  src 135.180.xxx.xxx dev br-lan scope link  src dev iot-no-net scope link  src dev iot-net scope link  src
135.180.xxx.xxx/22 dev eth1 scope link  src 135.180.xxx.xxx

It worked fine once I manually added the route:

ip -4 route add dev wg0

How do I get OpenWrt to add this route automatically? And if it can't be done, how would I configure this route in OpenWrt without having to manually run ip route?

In the peer config section of the openwrt router’s wireguard stanzas, be sure to enable ‘route_allowed_ips’

Wow, so simple! Thanks for your help again @psherman. Is there a reason that's not the default? It's the default behaviour of wg-quick.

There is no real “default” as each setup is unique and needs different things. It is a simple checkbox, though.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.