2020-12-26 00:30:20 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
imports =
|
|
|
|
[
|
|
|
|
./hardware-configuration.nix
|
|
|
|
../../configuration/common
|
|
|
|
../../configuration/router
|
|
|
|
];
|
|
|
|
|
|
|
|
boot.loader.grub.enable = true;
|
|
|
|
boot.loader.grub.version = 2;
|
|
|
|
boot.loader.grub.device = "/dev/sda";
|
|
|
|
|
|
|
|
networking.hostName = "gatekeeper";
|
|
|
|
|
|
|
|
networking.useDHCP = false;
|
|
|
|
# Local Router IPs
|
|
|
|
networking.interfaces.lo.ipv6.addresses = [
|
|
|
|
{ address = "fd00:152:152:101::1"; prefixLength = 64; }
|
|
|
|
{ address = "fd00:152:152::1"; prefixLength = 128; } # Anycast
|
|
|
|
];
|
|
|
|
networking.interfaces.lo.ipv4.addresses = [
|
|
|
|
{ address = "10.152.101.1"; prefixLength = 24; }
|
|
|
|
{ address = "10.152.0.1"; prefixLength = 32; } # Anycast
|
|
|
|
];
|
|
|
|
# Network
|
|
|
|
networking.interfaces.ens3.ipv4.addresses = [ { address = "78.47.183.82"; prefixLength = 32; } ];
|
|
|
|
networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:c0c:15f1::1"; prefixLength = 64; } ];
|
|
|
|
networking.defaultGateway = { address = "172.31.1.1"; interface = "ens3"; };
|
|
|
|
networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
|
|
|
|
networking.nameservers = [ "213.133.98.98" "213.133.99.99" "213.133.100.100" ];
|
|
|
|
|
2020-12-26 01:50:50 +01:00
|
|
|
networking.nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "ens3";
|
|
|
|
internalInterfaces = [ "wg-vpn" ];
|
|
|
|
internalIPs = [ "10.20.30.0/24" ];
|
|
|
|
};
|
|
|
|
|
2020-12-26 00:30:20 +01:00
|
|
|
networking.wireguard.enable = true;
|
|
|
|
networking.wireguard.interfaces = {
|
2021-02-03 19:47:12 +01:00
|
|
|
wg-carbon4 = {
|
2021-01-10 18:47:11 +01:00
|
|
|
ips = [ "fe80::127:1/64" "169.254.127.1/24" ];
|
|
|
|
peers = [ {
|
|
|
|
allowedIPs = [ "0.0.0.0/0" "::/0" ];
|
|
|
|
publicKey = "5EVyQC0y704asO4SwsGbAoFGKusuO4a6IJ2bS/5bcTI=";
|
|
|
|
} ];
|
|
|
|
listenPort = 50127;
|
|
|
|
allowedIPsAsRoutes = false;
|
2021-02-03 19:47:12 +01:00
|
|
|
privateKeyFile = "/var/src/secrets/wireguard/wg-carbon4";
|
2021-01-10 18:47:11 +01:00
|
|
|
};
|
2021-02-03 20:14:59 +01:00
|
|
|
wg-porter6 = {
|
|
|
|
ips = [ "fe80::101:1/64" "169.254.101.1/24" ];
|
|
|
|
peers = [ {
|
|
|
|
allowedIPs = [ "0.0.0.0/0" "::/0" ];
|
|
|
|
endpoint = "[2a03:4000:6:48d::1]:50101";
|
|
|
|
publicKey = "Jr1GBeNWrYjz7QyiI8XSOSRo/kGsCCtGGAzxmM5Hkn0=";
|
|
|
|
} ];
|
|
|
|
listenPort = 50101;
|
|
|
|
allowedIPsAsRoutes = false;
|
|
|
|
privateKeyFile = "/var/src/secrets/wireguard/wg-porter6";
|
|
|
|
};
|
2021-02-03 19:47:12 +01:00
|
|
|
wg-nonat6 = {
|
2021-01-10 18:47:11 +01:00
|
|
|
ips = [ "fe80::128:1/64" "169.254.128.1/24" ];
|
|
|
|
peers = [ {
|
|
|
|
allowedIPs = [ "0.0.0.0/0" "::/0" ];
|
2021-02-03 19:47:12 +01:00
|
|
|
endpoint = "[2001:638:904:ffca::6]:50128";
|
2021-01-10 18:47:11 +01:00
|
|
|
publicKey = "0GGDyPj/0uMaba9pmOyj+Sx+3jMivpRdpTJhadl6bS8=";
|
|
|
|
} ];
|
|
|
|
listenPort = 50128;
|
|
|
|
allowedIPsAsRoutes = false;
|
2021-02-03 19:47:12 +01:00
|
|
|
privateKeyFile = "/var/src/secrets/wireguard/wg-nonat6";
|
2021-01-10 18:47:11 +01:00
|
|
|
};
|
2021-05-12 10:04:04 +02:00
|
|
|
wg-heimnetz = {
|
|
|
|
ips = [ "fd00:153:153:201::1/64" ];
|
|
|
|
peers = [ {
|
|
|
|
allowedIPs = [ "::/0" ];
|
|
|
|
endpoint = "[fd00:152:152:104::1]:60001";
|
|
|
|
publicKey = "x44tpGt+uqIWTEl4qwZE7iPRjEHkYSZGKOQ7EuwLzX8=";
|
|
|
|
} ];
|
|
|
|
listenPort = 60001;
|
|
|
|
allowedIPsAsRoutes = false;
|
|
|
|
privateKeyFile = "/var/src/secrets/wireguard/wg-heimnetz";
|
|
|
|
postSetup = "ip link set wg-heimnetz mtu 1340";
|
|
|
|
};
|
2020-12-26 00:30:20 +01:00
|
|
|
wg-vpn = {
|
|
|
|
ips = [ "2a01:4f8:c0c:15f1::8001/113" "10.20.30.1/24" ];
|
|
|
|
peers = [
|
|
|
|
{
|
|
|
|
# krypton
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8011/128" "10.20.30.11/32" ];
|
|
|
|
publicKey = "NA/vdmoKQ5bpPKKrRPUpI17bNPoviRXnZ61iV4Q1VUQ=";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# krypton full
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8111/128" "10.20.30.111/32" ];
|
|
|
|
publicKey = "QGQHWwDE1XIeiReFcacLxin4Dqlz1pBXvttFnzBMJSY=";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# nexus
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8012/128" "10.20.30.12/32" ];
|
|
|
|
publicKey = "tEJzPPEJkoTPkhzTWyFDZ+5U146ovHA/4Mv3JButSAQ=";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# terra
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8014/128" "10.20.30.14/32" ];
|
|
|
|
publicKey = "peZ94x44sMRNqNxcaN+DI2UMwVFzugZjnnbqbxWcBEs=";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# palladium
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8103/128" "10.20.30.103/32" ];
|
|
|
|
publicKey = "kxn69ynVyPJeShsAlVz5Xnd7U74GmCAw181b0+/qj3k=";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
allowedIPs = [ "2a01:4f8:c0c:15f1::8104/128" "10.20.30.104/32" ];
|
|
|
|
publicKey = "k1eQINwZPRdIEhND5sKAcHMxEpz/Z+B/2ZCdLhHCG3w=";
|
|
|
|
}
|
|
|
|
];
|
2020-12-26 10:17:31 +01:00
|
|
|
listenPort = 51820;
|
2020-12-26 00:30:20 +01:00
|
|
|
allowedIPsAsRoutes = false;
|
|
|
|
privateKeyFile = "/var/src/secrets/wireguard/wg-vpn";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-11 16:21:35 +02:00
|
|
|
networking.firewall.allowedUDPPorts = [ 53 993 995 50101 50127 50128 51820 60001 ];
|
|
|
|
networking.firewall.extraCommands = ''
|
|
|
|
iptables -t nat -I PREROUTING -p udp -m multiport --dports 53,993,995 -j REDIRECT --to-ports 51820
|
|
|
|
'';
|
2020-12-26 10:17:31 +01:00
|
|
|
|
2020-12-26 01:49:13 +01:00
|
|
|
clerie.nginx-port-forward = {
|
|
|
|
enable = true;
|
|
|
|
tcpPorts."443" = {
|
|
|
|
host = "localhost";
|
|
|
|
port = 22;
|
|
|
|
};
|
|
|
|
tcpPorts."2022" = {
|
|
|
|
host = "nonat.net.clerie.de";
|
|
|
|
port = 22;
|
|
|
|
};
|
2021-02-10 21:05:06 +01:00
|
|
|
# riese
|
|
|
|
tcpPorts."25566" = {
|
|
|
|
host = "minecraft-2.net.clerie.de";
|
|
|
|
port = 25566;
|
|
|
|
};
|
|
|
|
# chaos
|
|
|
|
tcpPorts."25568" = {
|
|
|
|
host = "minecraft-2.net.clerie.de";
|
|
|
|
port = 25568;
|
|
|
|
};
|
|
|
|
# aerilon
|
2021-02-06 18:54:51 +01:00
|
|
|
tcpPorts."25569" = {
|
|
|
|
host = "minecraft-2.net.clerie.de";
|
|
|
|
port = 25565;
|
|
|
|
};
|
2020-12-26 01:49:13 +01:00
|
|
|
};
|
|
|
|
|
2021-01-10 18:47:11 +01:00
|
|
|
services.bird2.enable = true;
|
|
|
|
services.bird2.config = ''
|
|
|
|
router id ${ (lib.head config.networking.interfaces.lo.ipv4.addresses).address };
|
|
|
|
|
|
|
|
ipv6 table ospf6;
|
|
|
|
ipv4 table ospf4;
|
|
|
|
|
|
|
|
protocol direct {
|
|
|
|
interface "lo";
|
|
|
|
ipv6 {
|
|
|
|
table ospf6;
|
|
|
|
};
|
|
|
|
ipv4 {
|
|
|
|
table ospf4;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol kernel kernel_ospf6 {
|
|
|
|
ipv6 {
|
|
|
|
table ospf6;
|
|
|
|
export filter {
|
|
|
|
krt_prefsrc=${ (lib.head config.networking.interfaces.lo.ipv6.addresses).address };
|
|
|
|
accept;
|
|
|
|
};
|
|
|
|
import none;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol kernel kernel_ospf4 {
|
|
|
|
ipv4 {
|
|
|
|
table ospf4;
|
|
|
|
export filter {
|
|
|
|
krt_prefsrc=${ (lib.head config.networking.interfaces.lo.ipv4.addresses).address };
|
|
|
|
accept;
|
|
|
|
};
|
|
|
|
import none;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol ospf v3 ospf_6 {
|
|
|
|
ipv6 {
|
|
|
|
table ospf6;
|
|
|
|
import all;
|
|
|
|
export all;
|
|
|
|
};
|
|
|
|
area 0 {
|
2021-02-03 19:47:12 +01:00
|
|
|
interface "wg-carbon4" {
|
2021-01-10 18:47:11 +01:00
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
2021-02-03 20:14:59 +01:00
|
|
|
interface "wg-porter6" {
|
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
2021-02-03 19:47:12 +01:00
|
|
|
interface "wg-nonat6" {
|
2021-01-10 18:47:11 +01:00
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol ospf v3 ospf_4 {
|
|
|
|
ipv4 {
|
|
|
|
table ospf4;
|
|
|
|
import all;
|
|
|
|
export all;
|
|
|
|
};
|
|
|
|
area 0 {
|
2021-02-03 19:47:12 +01:00
|
|
|
interface "wg-carbon4" {
|
2021-01-10 18:47:11 +01:00
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
2021-02-03 20:14:59 +01:00
|
|
|
interface "wg-porter6" {
|
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
2021-02-03 19:47:12 +01:00
|
|
|
interface "wg-nonat6" {
|
2021-01-10 18:47:11 +01:00
|
|
|
cost 80;
|
|
|
|
type pointopoint;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protocol device {
|
|
|
|
scan time 10;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2021-02-24 02:20:38 +01:00
|
|
|
clerie.monitoring = {
|
|
|
|
enable = true;
|
|
|
|
id = "101";
|
|
|
|
pubkey = "H9Pvx/BzwEMM7acT9mioT8zBD2Yn13L82EKKqdAfeGM=";
|
|
|
|
};
|
|
|
|
|
2020-12-26 00:30:20 +01:00
|
|
|
system.stateVersion = "21.03";
|
|
|
|
}
|