Archived
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9b225d2d6 |
No files matched your search
@@ -77,14 +77,6 @@ creation_rules:
|
|||||||
- *admin
|
- *admin
|
||||||
- *lxc-tor-relay
|
- *lxc-tor-relay
|
||||||
|
|
||||||
- path_regex: secrets/tailscale-router\.yaml$
|
|
||||||
key_groups:
|
|
||||||
- age:
|
|
||||||
- *admin
|
|
||||||
- *linode-tailscale-router
|
|
||||||
- *lxc-tailscale-router
|
|
||||||
- *proxmox-tailscale-router
|
|
||||||
|
|
||||||
# gui-host-specific secrets (currently: wifi-password, see
|
# gui-host-specific secrets (currently: wifi-password, see
|
||||||
# modules/networking/wifi.nix). Only *lxc-gui has a registered key today
|
# modules/networking/wifi.nix). Only *lxc-gui has a registered key today
|
||||||
# -- proxmox-gui/linode-gui/baremetal-gui haven't been provisioned via
|
# -- proxmox-gui/linode-gui/baremetal-gui haven't been provisioned via
|
||||||
|
|||||||
@@ -1,19 +1,8 @@
|
|||||||
_:
|
_:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
|
||||||
(import ../../modules/beszel/host-token.nix {
|
|
||||||
name = "tailscale-router";
|
|
||||||
sopsFile = ../../secrets/tailscale-router.yaml;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
networking.hostName = "tailscale-router";
|
networking.hostName = "tailscale-router";
|
||||||
|
|
||||||
services.beszel.agent.environment = {
|
|
||||||
KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFPR9kwtC4TAeTRu46A7+opZsYpxqkRJ+x/ZyB2GWCeG";
|
|
||||||
};
|
|
||||||
|
|
||||||
# No networking.hostId: only ZFS-touching hosts (server, docker) need one
|
# No networking.hostId: only ZFS-touching hosts (server, docker) need one
|
||||||
# for pool-import safety, and this host does neither.
|
# for pool-import safety, and this host does neither.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../tailscale/subnet-router.nix
|
../tailscale/subnet-router.nix
|
||||||
../beszel/enable-agent.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# "server", not "both": this build type advertises LAN subnet routes but
|
# "server", not "both": this build type advertises LAN subnet routes but
|
||||||
@@ -17,29 +16,27 @@
|
|||||||
# Must also be approved in the Tailscale admin console (Machines → Edit route settings).
|
# Must also be approved in the Tailscale admin console (Machines → Edit route settings).
|
||||||
services.tailscale.extraUpFlags = [ "--advertise-routes=${vars.lanCidr}" ];
|
services.tailscale.extraUpFlags = [ "--advertise-routes=${vars.lanCidr}" ];
|
||||||
|
|
||||||
networking = {
|
networking.firewall = {
|
||||||
# SNAT traffic from LAN machines going out through Tailscale so the remote
|
# Forwarded subnet-router traffic arrives on tailscale0 already
|
||||||
# peer sees it sourced from this router's Tailscale IP (100.x.x.x) rather
|
# tailscale-authenticated -- the firewall's normal per-port allow-list
|
||||||
# than a raw LAN IP. Without this, Tailscale drops the forwarded packets
|
# would otherwise drop it. Standard NixOS/Tailscale subnet-router guidance.
|
||||||
# because the source is not a recognised Tailscale address.
|
trustedInterfaces = [ "tailscale0" ];
|
||||||
#
|
|
||||||
# networking.nat.externalInterface alone does not insert a MASQUERADE rule
|
|
||||||
# (it only does so when internalInterfaces is also set). We use
|
|
||||||
# extraCommands to add the rule into the nixos-nat-post chain that
|
|
||||||
# networking.nat.enable creates, and extraStopCommands to clean it up.
|
|
||||||
nat.enable = true;
|
|
||||||
|
|
||||||
firewall = {
|
# SNAT LAN traffic going into Tailscale so the remote peer sees it as
|
||||||
# Forwarded subnet-router traffic arrives on tailscale0 already
|
# coming from this router's Tailscale IP rather than a raw LAN IP.
|
||||||
# tailscale-authenticated -- the firewall's normal per-port allow-list
|
# Without this, Tailscale drops forwarded packets whose source is not a
|
||||||
# would otherwise drop it. Standard NixOS/Tailscale subnet-router guidance.
|
# recognised Tailscale address.
|
||||||
trustedInterfaces = [ "tailscale0" ];
|
#
|
||||||
extraCommands = ''
|
# We target POSTROUTING directly (always-existing built-in chain) rather
|
||||||
iptables -t nat -A nixos-nat-post -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE
|
# than nixos-nat-post: extraCommands runs after the old nixos-nat-post is
|
||||||
'';
|
# deleted but before the new one is created, so -A nixos-nat-post silently
|
||||||
extraStopCommands = ''
|
# fails. The -C check makes the rule idempotent across firewall reloads.
|
||||||
iptables -t nat -D nixos-nat-post -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE 2>/dev/null || true
|
extraCommands = ''
|
||||||
'';
|
iptables -t nat -C POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE 2>/dev/null || \
|
||||||
};
|
iptables -t nat -A POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE
|
||||||
|
'';
|
||||||
|
extraStopCommands = ''
|
||||||
|
iptables -t nat -D POSTROUTING -s ${vars.lanCidr} -o tailscale0 -j MASQUERADE 2>/dev/null || true
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user