Setup mail server and restructure some things
This commit is contained in:
parent
4c382e629d
commit
ba93d164cf
90 changed files with 512 additions and 66 deletions
69
config/hosts/lifeline/configuration.nix
Normal file
69
config/hosts/lifeline/configuration.nix
Normal file
|
@ -0,0 +1,69 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
boot.loader.grub = {
|
||||
enable = true;
|
||||
device = "/dev/vda";
|
||||
};
|
||||
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true;
|
||||
|
||||
networking = {
|
||||
hostName = "lifeline";
|
||||
useDHCP = true;
|
||||
wireguard = {
|
||||
enable = true;
|
||||
interfaces.wg0 = {
|
||||
privateKeyFile = "/secrets/wireguard-lifeline-mail-1-lifeline-privatekey.secret";
|
||||
listenPort = 51820;
|
||||
ips = [
|
||||
"172.16.50.1/24"
|
||||
];
|
||||
peers = [
|
||||
{
|
||||
name = "mail-1";
|
||||
publicKey = "CyKPjkY1ah/lE6V3R0XugNo28doeAtD8wEtAeDB7bHs=";
|
||||
presharedKeyFile = "/secrets/wireguard-lifeline-mail-1-lifeline-psk.secret";
|
||||
allowedIPs = [ "172.16.50.2/32" ];
|
||||
}
|
||||
];
|
||||
postSetup = ''
|
||||
${pkgs.iptables}/bin/iptables -A FORWARD -i wg0 -j ACCEPT
|
||||
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 172.16.50.0/24 -o ens6 -j MASQUERADE
|
||||
'';
|
||||
postShutdown = ''
|
||||
${pkgs.iptables}/bin/iptables -D FORWARD -i wg0 -j ACCEPT
|
||||
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 172.16.50.0/24 -o ens6 -j MASQUERADE
|
||||
'';
|
||||
};
|
||||
};
|
||||
nat = {
|
||||
enable = true;
|
||||
internalInterfaces = [ "wg0" ];
|
||||
externalInterface = "ens6";
|
||||
forwardPorts = [
|
||||
{
|
||||
destination = "172.16.50.2:25";
|
||||
proto = "tcp";
|
||||
sourcePort = 25;
|
||||
}
|
||||
{
|
||||
destination = "172.16.50.2:465";
|
||||
proto = "tcp";
|
||||
sourcePort = 465;
|
||||
}
|
||||
{
|
||||
destination = "172.16.50.2:993";
|
||||
proto = "tcp";
|
||||
sourcePort = 993;
|
||||
}
|
||||
];
|
||||
};
|
||||
firewall = {
|
||||
allowedUDPPorts = [ 51820 ];
|
||||
};
|
||||
};
|
||||
|
||||
services.prometheus.exporters.node.enable = false;
|
||||
|
||||
system.stateVersion = "23.05";
|
||||
}
|
7
config/hosts/lifeline/default.nix
Normal file
7
config/hosts/lifeline/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
}
|
16
config/hosts/lifeline/hardware-configuration.nix
Normal file
16
config/hosts/lifeline/hardware-configuration.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd = {
|
||||
availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
|
||||
kernelModules = [ "nvme" ];
|
||||
};
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/vda1";
|
||||
fsType = "ext4";
|
||||
};
|
||||
}
|
19
config/hosts/lifeline/secrets.nix
Normal file
19
config/hosts/lifeline/secrets.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ ... }:
|
||||
{
|
||||
deployment.keys."wireguard-lifeline-mail-1-lifeline-psk.secret" = {
|
||||
keyCommand = [ "env" "GNUPGHOME=/home/yuri/.passinfra_gnupg" "PASSWORD_STORE_DIR=/home/yuri/pass/infra" "pass" "wireguard/lifeline-mail-1/psk" ];
|
||||
destDir = "/secrets";
|
||||
user = "root";
|
||||
group = "root";
|
||||
permissions = "0640";
|
||||
uploadAt = "pre-activation";
|
||||
};
|
||||
deployment.keys."wireguard-lifeline-mail-1-lifeline-privatekey.secret" = {
|
||||
keyCommand = [ "env" "GNUPGHOME=/home/yuri/.passinfra_gnupg" "PASSWORD_STORE_DIR=/home/yuri/pass/infra" "pass" "wireguard/lifeline-mail-1/lifeline-privatekey" ];
|
||||
destDir = "/secrets";
|
||||
user = "root";
|
||||
group = "root";
|
||||
permissions = "0640";
|
||||
uploadAt = "pre-activation";
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue