diff --git a/internal/wireguard/route.go b/internal/wireguard/route.go index 84178d032..9893dc760 100644 --- a/internal/wireguard/route.go +++ b/internal/wireguard/route.go @@ -32,9 +32,14 @@ func (w *Wireguard) addRoutes(link netlink.Link, destinations []netip.Prefix, func (w *Wireguard) addRoute(link netlink.Link, dst netip.Prefix, firewallMark uint32, ) (err error) { + family := netlink.FamilyV4 + if dst.Addr().Is6() { + family = netlink.FamilyV6 + } route := netlink.Route{ LinkIndex: link.Index, Dst: dst, + Family: family, Table: int(firewallMark), } diff --git a/internal/wireguard/route_test.go b/internal/wireguard/route_test.go index 57e48afa4..ce05ac602 100644 --- a/internal/wireguard/route_test.go +++ b/internal/wireguard/route_test.go @@ -37,6 +37,7 @@ func Test_Wireguard_addRoute(t *testing.T) { expectedRoute: netlink.Route{ LinkIndex: linkIndex, Dst: ipPrefix, + Family: netlink.FamilyV4, Table: firewallMark, }, }, @@ -49,6 +50,7 @@ func Test_Wireguard_addRoute(t *testing.T) { expectedRoute: netlink.Route{ LinkIndex: linkIndex, Dst: ipPrefix, + Family: netlink.FamilyV4, Table: firewallMark, }, routeAddErr: errDummy,