Compare commits
2 Commits
ad87c67161
...
a3a85c3596
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a3a85c3596 | ||
![]() |
279d00ae82 |
@ -1,40 +1,12 @@
|
|||||||
{
|
{config, ...}: {
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
useRoutingFeatures = "client";
|
authKeyFile = config.age.secrets.tailscale-key.path;
|
||||||
|
useRoutingFeatures = "both";
|
||||||
|
extraUpFlags = [
|
||||||
|
"--login-server=https://va.m3tam3re.com"
|
||||||
|
"--accept-routes"
|
||||||
|
"--exit-node-allow-lan-access"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# systemd.services.tailscale-autoconnect = {
|
|
||||||
# description = "Automatic connection to Tailscale";
|
|
||||||
|
|
||||||
# # make sure tailscale is running before trying to connect to tailscale
|
|
||||||
# after = ["network-pre.target" "tailscale.service"];
|
|
||||||
# wants = ["network-pre.target" "tailscale.service"];
|
|
||||||
# wantedBy = ["multi-user.target"];
|
|
||||||
|
|
||||||
# # set this service as a oneshot job
|
|
||||||
# serviceConfig = {
|
|
||||||
# Type = "oneshot";
|
|
||||||
# EnvironmentFile = "${config.age.secrets.tailscale-key.path}";
|
|
||||||
# };
|
|
||||||
|
|
||||||
# # have the job run this shell script
|
|
||||||
# script = with pkgs; ''
|
|
||||||
# # wait for tailscaled to settle
|
|
||||||
# sleep 2
|
|
||||||
|
|
||||||
# # check if we are already authenticated to tailscale
|
|
||||||
# status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)"
|
|
||||||
# if [ $status = "Running" ]; then # if so, then do nothing
|
|
||||||
# exit 0
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# # otherwise authenticate with tailscale
|
|
||||||
# ${tailscale}/bin/tailscale up --exit-node 100.88.96.77 --authkey $TAILSCALE_KEY
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
# Define a new option for the admin user
|
# Define a new option for the admin user
|
||||||
@ -42,14 +42,12 @@
|
|||||||
routes = {
|
routes = {
|
||||||
"0.0.0.0/0" = ["${adminUser}"];
|
"0.0.0.0/0" = ["${adminUser}"];
|
||||||
"10.0.0.0/8" = ["${adminUser}"];
|
"10.0.0.0/8" = ["${adminUser}"];
|
||||||
"172.16.0.0/12" = ["${adminUser}"];
|
|
||||||
"192.168.0.0/16" = ["${adminUser}"];
|
"192.168.0.0/16" = ["${adminUser}"];
|
||||||
};
|
};
|
||||||
|
|
||||||
exitNode = ["${adminUser}"];
|
exitNode = ["${adminUser}"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Convert to HuJSON format with comments
|
# Convert to HuJSON format with comments
|
||||||
aclHuJson = ''
|
aclHuJson = ''
|
||||||
// Headscale ACL Policy - Generated by NixOS
|
// Headscale ACL Policy - Generated by NixOS
|
||||||
@ -57,14 +55,13 @@
|
|||||||
|
|
||||||
${builtins.toJSON aclConfig}
|
${builtins.toJSON aclConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
aclFile = pkgs.writeText "acl-policy.hujson" aclHuJson;
|
aclFile = pkgs.writeText "acl-policy.hujson" aclHuJson;
|
||||||
in {
|
in {
|
||||||
services = {
|
services = {
|
||||||
headscale = {
|
headscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 3009;
|
|
||||||
adminUser = "m3tam3re";
|
adminUser = "m3tam3re";
|
||||||
|
port = 3009;
|
||||||
settings = {
|
settings = {
|
||||||
server_url = "https://va.m3tam3re.com";
|
server_url = "https://va.m3tam3re.com";
|
||||||
dns = {
|
dns = {
|
||||||
@ -76,24 +73,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Traefik configuration
|
|
||||||
services.traefik.dynamicConfigOptions.http = {
|
|
||||||
services.headscale.loadBalancer.servers = [
|
|
||||||
{
|
|
||||||
url = "http://localhost:3009/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
routers.headscale = {
|
|
||||||
rule = "Host(`va.m3tam3re.com`)";
|
|
||||||
tls = {
|
|
||||||
certResolver = "godaddy";
|
|
||||||
};
|
|
||||||
service = "headscale";
|
|
||||||
entrypoints = "websecure";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Create a systemd service to ensure the admin user exists
|
# Create a systemd service to ensure the admin user exists
|
||||||
systemd.services.headscale-ensure-admin = lib.mkIf config.services.headscale.enable {
|
systemd.services.headscale-ensure-admin = lib.mkIf config.services.headscale.enable {
|
||||||
description = "Ensure Headscale admin user exists";
|
description = "Ensure Headscale admin user exists";
|
||||||
@ -117,5 +96,23 @@
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Traefik configuration for headscale
|
||||||
|
services.traefik.dynamicConfigOptions.http = {
|
||||||
|
services.headscale.loadBalancer.servers = [
|
||||||
|
{
|
||||||
|
url = "http://localhost:3009/";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
routers.headscale = {
|
||||||
|
rule = "Host(`va.m3tam3re.com`)";
|
||||||
|
tls = {
|
||||||
|
certResolver = "godaddy";
|
||||||
|
};
|
||||||
|
service = "headscale";
|
||||||
|
entrypoints = "websecure";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,27 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
useRoutingFeatures = "both";
|
|
||||||
authKeyFile = config.age.secrets.tailscale-key.path;
|
authKeyFile = config.age.secrets.tailscale-key.path;
|
||||||
|
useRoutingFeatures = "both";
|
||||||
extraUpFlags = [
|
extraUpFlags = [
|
||||||
"--login-server=${config.services.headscale.settings.server_url}"
|
"--login-server=${config.services.headscale.settings.server_url}"
|
||||||
"--advertise-exit-node"
|
"--advertise-exit-node"
|
||||||
"--accept-routes"
|
"--accept-routes"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
services.networkd-dispatcher = lib.mkIf config.services.tailscale.enable {
|
||||||
services.networkd-dispatcher = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
rules."50-tailscale" = {
|
rules."50-tailscale" = {
|
||||||
onState = ["routable"];
|
onState = ["routable"];
|
||||||
script = ''
|
script = ''
|
||||||
"${pkgs.ethtool} NETDEV=$(ip -o route get 8.8.8.8 | cut -f 5 -d " ") | -K $NETDEV rx-udp-gro-forwarding on rx-gro-list off
|
NETDEV=$(ip -o route get 8.8.8.8 | cut -f 5 -d " ")
|
||||||
|
${pkgs.ethtool}/bin/ethtool -K $NETDEV rx-udp-gro-forwarding on rx-gro-list off
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.kernel.sysctl = {
|
|
||||||
"net.ipv4.ip_forward" = 1;
|
|
||||||
"net.ipv6.conf.all.forwarding" = 1;
|
|
||||||
"net.core.gro_normal_batch" = 8;
|
|
||||||
"net.core.gro_flush_timeout" = 200000;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall = {
|
|
||||||
trustedInterfaces = ["tailscale0"];
|
|
||||||
allowedUDPPorts = [41641];
|
|
||||||
checkReversePath = "loose";
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
ethtool
|
|
||||||
tailscale
|
|
||||||
networkd-dispatcher
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
age = {
|
age = {
|
||||||
secrets = {
|
secrets = {
|
||||||
|
tailscale-key = {
|
||||||
|
file = ../../secrets/tailscale-key.age;
|
||||||
|
};
|
||||||
wg-DE = {
|
wg-DE = {
|
||||||
file = ../../secrets/wg-DE.age;
|
file = ../../secrets/wg-DE.age;
|
||||||
path = "/etc/wireguard/DE.conf";
|
path = "/etc/wireguard/DE.conf";
|
||||||
@ -21,7 +24,6 @@
|
|||||||
file = ../../secrets/wg-BR.age;
|
file = ../../secrets/wg-BR.age;
|
||||||
path = "/etc/wireguard/BR.conf";
|
path = "/etc/wireguard/BR.conf";
|
||||||
};
|
};
|
||||||
tailscale-key.file = ../../secrets/tailscale-key.age;
|
|
||||||
m3tam3re-secrets = {
|
m3tam3re-secrets = {
|
||||||
file = ../../secrets/m3tam3re-secrets.age;
|
file = ../../secrets/m3tam3re-secrets.age;
|
||||||
owner = "m3tam3re";
|
owner = "m3tam3re";
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{
|
{config, ...}: {
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
useRoutingFeatures = "client";
|
authKeyFile = config.age.secrets.tailscale-key.path;
|
||||||
|
useRoutingFeatures = "both";
|
||||||
extraUpFlags = [
|
extraUpFlags = [
|
||||||
"--login-server https://va.m3tam3re.com"
|
"--login-server=https://va.m3tam3re.com"
|
||||||
"--exit-node=m3-atlas"
|
"--accept-routes"
|
||||||
"--exit-node-allow-lan-access"
|
"--exit-node-allow-lan-access"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user