all repos — nixfiles @ 9ceb482b714b5a2d39f0898323ffc33ea2eae1ca

System and user configuration, managed by nix and home-manager

system/roles/tailscale-subnet-router.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  config,
  lib,
  ...
}:
let
  lan = builtins.head config.networking.nat.internalInterfaces;

  networks = [
    "10.0.0.0/16"
    "fd12:d04f:65d::/56"
  ];
in
{
  networking.firewall.extraForwardRules = ''
    iifname "tailscale0" oifname "${lan}" accept
    iifname "${lan}" oifname "tailscale0" accept
  '';

  services.tailscale.extraSetFlags = [
    "--advertise-routes"
    (lib.join "," networks)
  ];
}