finally works again
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
networking.firewall.enable = true;
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
|
||||
networking.nftables.enable = true;
|
||||
networking.nftables.tables.nat = {
|
||||
family = "ip";
|
||||
content = ''
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority dstnat; policy accept;
|
||||
|
||||
iifname "enp1s0" tcp dport 80 dnat to 10.0.0.2:80
|
||||
iifname "enp1s0" tcp dport 443 dnat to 10.0.0.2:443
|
||||
}
|
||||
chain postrouting {
|
||||
type nat hook postrouting priority srcnat; policy accept;
|
||||
|
||||
oifname "wg0" masquerade
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
boot.kernel.sysctl = {
|
||||
"net.ipv4.ip_forward" = 1;
|
||||
};
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
options.network = {
|
||||
nodes = lib.mkOption { type = lib.types.attrsOf
|
||||
(lib.types.submodule ({ name, config, ... }: {
|
||||
options = {
|
||||
id = lib.mkOption { type = lib.types.int; };
|
||||
ssh = lib.mkOption { type = lib.types.str; };
|
||||
vpn = lib.mkOption { type = lib.types.str; };
|
||||
address-vpn = lib.mkOption { type = lib.types.str; };
|
||||
address-pub = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; };
|
||||
};
|
||||
config = {
|
||||
address-vpn = "10.0.0.${toString config.id}";
|
||||
};
|
||||
}));
|
||||
};
|
||||
node = lib.mkOption { type = lib.types.str; };
|
||||
};
|
||||
config.network = {
|
||||
nodes = {
|
||||
laptop = {
|
||||
id = 1;
|
||||
ssh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhCH6YN63AWFsR1wZ6wJdZ2jlTtYBSkY5FnLrWoLKeg";
|
||||
vpn = "n+9eh8VUP9NCnjPL0Z/KPc0TQCQloXE2Ipc5+CBtJjU=";
|
||||
};
|
||||
desktop = {
|
||||
id = 2;
|
||||
ssh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFdOUv+mUhnS2sbahlqcqm9Ili16/rOk2WAlMSXrjnHu";
|
||||
vpn = "7BcwtszpzS4ABDwKwMaiJ7F35sJRa89fBbuh80Sk8Uk=";
|
||||
};
|
||||
vps = {
|
||||
id = 3;
|
||||
ssh = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGiiLFiy+UcOi0RgZ1Xvuzl4C5aiZ+bcGaOmQcI/UBXp";
|
||||
vpn = "c5irm217aE+QVwHYmnQh4r91u2fZmQKBIWVgFVMaEwU=";
|
||||
address-pub = "216.128.177.13";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -23,11 +23,5 @@ in
|
||||
root * ${website}/blog
|
||||
file_server
|
||||
'';
|
||||
|
||||
virtualHosts."birds.grasswren.net".extraConfig = ''
|
||||
encode
|
||||
root * ${website}/birds
|
||||
file_server
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts."image.grasswren.net".extraConfig = ''
|
||||
virtualHosts."photo.grasswren.net".extraConfig = ''
|
||||
reverse_proxy localhost:2283
|
||||
'';
|
||||
};
|
||||
@@ -17,6 +17,7 @@
|
||||
dns = {
|
||||
magic_domain = true;
|
||||
base_domain = "vpn.grasswren.net";
|
||||
nameservers.global = [ "1.1.1.1" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
+6
-12
@@ -1,8 +1,5 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
me = config.network.nodes.${config.network.node};
|
||||
in
|
||||
{
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
@@ -16,19 +13,16 @@ in
|
||||
KbdInteractiveAuthentication = false;
|
||||
};
|
||||
listenAddresses = [{
|
||||
addr = me.address-vpn;
|
||||
addr = "0.0.0.0";
|
||||
port = 22;
|
||||
}];
|
||||
};
|
||||
|
||||
users.users.lilac.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhCH6YN63AWFsR1wZ6wJdZ2jlTtYBSkY5FnLrWoLKeg"
|
||||
];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
config.network.nodes.laptop.ssh
|
||||
config.network.nodes.desktop.ssh
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhCH6YN63AWFsR1wZ6wJdZ2jlTtYBSkY5FnLrWoLKeg"
|
||||
];
|
||||
users.users.lilac = lib.mkIf (config.network.node != "vps") {
|
||||
openssh.authorizedKeys.keys = [
|
||||
config.network.nodes.laptop.ssh
|
||||
config.network.nodes.desktop.ssh
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
services.tailscale.enable = true;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
me = config.network.nodes.${config.network.node};
|
||||
in
|
||||
{
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedUDPPorts = [ 51820 ];
|
||||
trustedInterfaces = [ "wg0" ];
|
||||
};
|
||||
wireguard.interfaces."wg0" = {
|
||||
ips = [ "${me.address-vpn}/24" ];
|
||||
listenPort = 51820;
|
||||
generatePrivateKeyFile = true;
|
||||
privateKeyFile = "/var/lib/wireguard/wg0.key";
|
||||
peers = lib.mapAttrsToList (name: peer: {
|
||||
publicKey = peer.vpn;
|
||||
allowedIPs =
|
||||
if config.network.node == "vps"
|
||||
then [ "${peer.address-vpn}/32" ]
|
||||
else [ "10.0.0.0/24" ];
|
||||
endpoint =
|
||||
if peer.address-pub != null
|
||||
then "${peer.address-pub}:51820"
|
||||
else null;
|
||||
persistentKeepalive =
|
||||
if peer.address-pub != null
|
||||
then 25
|
||||
else null;
|
||||
}) (lib.filterAttrs (name: _:
|
||||
if config.network.node == "vps"
|
||||
then name != "vps"
|
||||
else name == "vps"
|
||||
) config.network.nodes);
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user