Rework vpn config, change to VM

This commit is contained in:
Erwin Boskma 2022-10-05 19:21:46 +02:00
parent 688a3ce42d
commit 4d7dabf4ca
Signed by: erwin
GPG key ID: 270B20D17394F7E5
2 changed files with 77 additions and 35 deletions

View file

@ -1,4 +1,8 @@
{ self, ... } @ inputs: { { self, ... } @ inputs:
let
pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux;
in
{
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
../../users/root ../../users/root
@ -11,14 +15,57 @@
enable = true; enable = true;
remote-builders = true; remote-builders = true;
}; };
services = { };
wireguard = {
server = { networking = {
hostName = "vpn";
useDHCP = false;
nat = {
enable = true; enable = true;
externalInterface = "eth0"; externalInterface = "br0";
internalInterface = "wg0"; internalInterfaces = [ "wg0" ];
internalIPs = [ "10.1.0.0/24" ]; };
interfaces = {
br0 = {
ipv4.addresses = [{ address = "10.0.0.250"; prefixLength = 24; }];
};
eth1 = {
ipv4.addresses = [{ address = "10.2.0.20"; prefixLength = 24; }];
};
};
firewall.trustedInterfaces = [ "eth1" ];
bridges = {
br0 = {
interfaces = [ "eth0" ];
rstp = true;
};
};
defaultGateway = {
address = "10.2.0.1";
interface = "eth1";
};
nameservers = [ "10.0.0.254" ];
wireguard.interfaces = {
wg0 = {
ips = [ "10.1.0.0/24" ];
listenPort = 51820;
privateKeyFile = "/run/secrets/wireguard_key"; privateKeyFile = "/run/secrets/wireguard_key";
postSetup = [
"${pkgs.iptables}/bin/iptables -A FORWARD -i %i -j ACCEPT"
"${pkgs.iptables}/bin/iptables -A FORWARD -o %i -j ACCEPT"
"${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE"
];
postShutdown = [
"${pkgs.iptables}/bin/iptables -D FORWARD -i %i -j ACCEPT"
"${pkgs.iptables}/bin/iptables -D FORWARD -o %i -j ACCEPT"
"${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -o br0 -j MASQUERADE"
];
peers = [ peers = [
# horus # horus
# { # {
@ -42,7 +89,6 @@
}; };
}; };
}; };
};
boot.isContainer = true; boot.isContainer = true;
@ -54,10 +100,6 @@
services.openssh.enable = true; services.openssh.enable = true;
proxmoxLXC = {
privileged = true;
};
sops.defaultSopsFile = ./secrets.yaml; sops.defaultSopsFile = ./secrets.yaml;
sops.secrets = { sops.secrets = {
wireguard_key = { }; wireguard_key = { };

View file

@ -5,6 +5,6 @@
, ... , ...
}: { }: {
imports = [ imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix") (modulesPath + "/virtualisation/proxmox-image.nix")
]; ];
} }