Compare commits
6 commits
2347ba609d
...
5df6e93ae3
Author | SHA1 | Date | |
---|---|---|---|
5df6e93ae3 | |||
f590432b7d | |||
a7052e1b8f | |||
7e61ad0aac | |||
9cf30613f4 | |||
dfe00fabb4 |
2 changed files with 47 additions and 29 deletions
|
@ -3,34 +3,33 @@
|
||||||
{
|
{
|
||||||
networking.nat.enable = true;
|
networking.nat.enable = true;
|
||||||
networking.nat.enableIPv6 = true;
|
networking.nat.enableIPv6 = true;
|
||||||
networking.nat.internalInterfaces = [ "ve-pennykettle1" ];
|
networking.nat.internalInterfaces = [ "ve-pennykettle" ];
|
||||||
networking.nat.externalInterface = "ens3";
|
networking.nat.externalInterface = "ens3";
|
||||||
networking.firewall.allowedUDPPorts = [ 51821 ];
|
networking.nat.forwardPorts = [
|
||||||
|
{
|
||||||
# RA = Router Advertisement (how a host finds a gateway IPv6 address for
|
sourcePort = 51820;
|
||||||
# SLAAC or DHCPv6).
|
destination = "10.231.136.2:51820";
|
||||||
# networkd usually defaults this to true, but instead defaults it to false
|
proto = "udp";
|
||||||
# for ALL networks if ANY network has IPv6Forwarding enabled, on the
|
}
|
||||||
# (reasonable) assumption that a host doing IP forwarding is probably a
|
{
|
||||||
# network bridge.
|
sourcePort = 51820;
|
||||||
# The kernel's RA implementation does this too, and the NixOS networking.nat
|
destination = "[fc00::2]:51820";
|
||||||
# module explicitly overrides that with sysctl, but networkd doesn't pay
|
proto = "udp";
|
||||||
# attention to that.
|
}
|
||||||
# We thus explicitly enable it, as otherwise external IPv6 is broken.
|
];
|
||||||
systemd.network.networks."40-ens3".networkConfig.IPv6AcceptRA = true;
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
|
|
||||||
containers."pennykettle1" = {
|
containers."pennykettle" = {
|
||||||
privateNetwork = true;
|
privateNetwork = true;
|
||||||
extraVeths."ve-pennykettle1" = {
|
extraVeths."ve-pennykettle" = {
|
||||||
hostAddress = "10.231.136.1";
|
hostAddress = "10.231.136.1";
|
||||||
localAddress = "10.231.136.2";
|
localAddress = "10.231.136.2";
|
||||||
hostAddress6 = "fc00::1";
|
hostAddress6 = "fc00::1";
|
||||||
localAddress6 = "fc00::2";
|
localAddress6 = "fc00::2";
|
||||||
forwardPorts = [{ hostPort = 51821; }];
|
|
||||||
};
|
};
|
||||||
ephemeral = true;
|
ephemeral = true;
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
bindMounts."/run/secrets/wg-key".hostPath = config.age.secrets.protonvpn-pennykettle1.path;
|
bindMounts."/run/secrets/wg-key".hostPath = config.age.secrets.protonvpn-pennykettle.path;
|
||||||
|
|
||||||
config = { config, pkgs, ... }: {
|
config = { config, pkgs, ... }: {
|
||||||
system.stateVersion = "24.05";
|
system.stateVersion = "24.05";
|
||||||
|
@ -39,24 +38,23 @@
|
||||||
|
|
||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
networking.useHostResolvConf = false;
|
networking.useHostResolvConf = false;
|
||||||
networking.firewall.allowedUDPPorts = [ 51821 ];
|
networking.firewall.allowedUDPPorts = [ 51820 ];
|
||||||
systemd.network = {
|
systemd.network = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
networks."10-ve" = {
|
networks."10-ve-pennykettle" = {
|
||||||
matchConfig.Name = "ve-pennykettle1";
|
matchConfig.Name = "ve-pennykettle";
|
||||||
networkConfig.Address = [ "10.231.136.2/24" "fc00::2/64" ];
|
networkConfig.Address = [ "10.231.136.2/24" "fc00::2/64" ];
|
||||||
# linkConfig.RequiredForOnline = "routable";
|
linkConfig.RequiredForOnline = "yes";
|
||||||
routes = [{
|
routes = [{
|
||||||
Gateway = [ "10.231.136.1" "fc00::1" ];
|
Gateway = [ "10.231.136.1" "fc00::1" ];
|
||||||
Destination = "217.138.216.162";
|
Destination = "217.138.216.162";
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
||||||
networks."30-protonvpn" = {
|
networks."30-wg-protonvpn" = {
|
||||||
matchConfig.Name = "wg-protonvpn";
|
matchConfig.Name = "wg-protonvpn";
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
DefaultRouteOnDevice = true;
|
|
||||||
Address = [ "10.2.0.2/32" ];
|
Address = [ "10.2.0.2/32" ];
|
||||||
DNS = "10.2.0.1";
|
DNS = "10.2.0.1";
|
||||||
};
|
};
|
||||||
|
@ -64,33 +62,54 @@
|
||||||
RequiredForOnline = "yes";
|
RequiredForOnline = "yes";
|
||||||
ActivationPolicy = "always-up";
|
ActivationPolicy = "always-up";
|
||||||
};
|
};
|
||||||
|
routes = [
|
||||||
|
{ Gateway = [ "0.0.0.0" ]; }
|
||||||
|
{ Gateway = [ "::" ]; } # TODO: ipv6 out is still not working for unclear reasons
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
netdevs."30-protonvpn" = {
|
netdevs."30-wg-protonvpn" = {
|
||||||
netdevConfig = {
|
netdevConfig = {
|
||||||
Name = "wg-protonvpn";
|
Name = "wg-protonvpn";
|
||||||
Kind = "wireguard";
|
Kind = "wireguard";
|
||||||
Description = "WireGuard tunnel to ProtonVPN (DE#1; NAT: strict, no port forwarding)";
|
Description = "WireGuard tunnel to ProtonVPN (DE#1; NAT: strict, no port forwarding)";
|
||||||
};
|
};
|
||||||
wireguardConfig = {
|
wireguardConfig = {
|
||||||
ListenPort = 51821;
|
ListenPort = 51820;
|
||||||
PrivateKeyFile = "/run/secrets/wg-key";
|
PrivateKeyFile = "/run/secrets/wg-key";
|
||||||
};
|
};
|
||||||
wireguardPeers = [{
|
wireguardPeers = [{
|
||||||
PublicKey = "C+u+eQw5yWI2APCfVJwW6Ovj3g4IrTOfe+tMZnNz43s=";
|
PublicKey = "C+u+eQw5yWI2APCfVJwW6Ovj3g4IrTOfe+tMZnNz43s=";
|
||||||
AllowedIPs = "0.0.0.0/0";
|
AllowedIPs = [ "0.0.0.0/0" "::/0" ];
|
||||||
Endpoint = "217.138.216.162:51820";
|
Endpoint = "217.138.216.162:51820";
|
||||||
PersistentKeepalive = 5;
|
PersistentKeepalive = 5;
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.nat.enable = true;
|
||||||
|
networking.nat.enableIPv6 = true;
|
||||||
|
networking.nat.internalInterfaces = [ "ve-pennykettle" ];
|
||||||
|
networking.nat.externalInterface = "wg-protonvpn";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
age.secrets.protonvpn-pennykettle1 = {
|
age.secrets.protonvpn-pennykettle = {
|
||||||
file = ../../../secrets/protonvpn-pennykettle1.age;
|
file = ../../../secrets/protonvpn-pennykettle1.age;
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "systemd-network";
|
group = "systemd-network";
|
||||||
mode = "640";
|
mode = "640";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO: password-protect the proxy instead of relying on only listening over Tailscale
|
||||||
|
services.microsocks = {
|
||||||
|
enable = true;
|
||||||
|
port = 1080;
|
||||||
|
ip = "::";
|
||||||
|
outgoingBindIp = "fc00::2";
|
||||||
|
# authUsername = "testusername123";
|
||||||
|
# authPasswordFile = pkgs.writeText "testpassword" "testpassworddonotuse";
|
||||||
|
# execWrapper = "${lib.getExe pkgs.strace}";
|
||||||
|
};
|
||||||
|
networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ 1080 ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
networking.useNetworkd = true;
|
|
||||||
networking.interfaces.ens3.useDHCP = true;
|
networking.interfaces.ens3.useDHCP = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue