1
0
vcp-bula-nixfiles/hosts/pre-router/configuration.nix

95 lines
3.0 KiB
Nix
Raw Normal View History

2022-07-07 11:15:52 +02:00
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./nginx.nix
];
2022-07-07 11:15:52 +02:00
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "pre-router"; # Define your hostname.
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
networking.useDHCP = false;
#networking.interfaces.ens18.useDHCP = false;
#networking.interfaces.ens19.useDHCP = false;
environment.systemPackages = with pkgs; [
ethtool # manage NIC settings (offload, NIC feeatures, ...)
conntrack-tools # view network connection states
wireguard-tools
];
networking.nat = {
enable = true;
externalInterface = "ens18";
internalIPs = [
"10.42.0.0/16"
];
};
boot.kernel.sysctl = {
"net.ipv6.conf.all.forwarding" = true;
"net.ipv6.conf.default.forwarding" = true;
};
networking.interfaces.ens18.useDHCP = true;
networking.interfaces.ens19.useDHCP = false;
networking.interfaces.ens19.ipv6.addresses = [
{ address = "fd00:10:42:10::25"; prefixLength = 64; }
{ address = "2a01:4f8:1c0c:8221::25"; prefixLength = 64; }
];
networking.interfaces.ens19.ipv4.addresses = [
{ address = "10.42.10.25"; prefixLength = 24; }
];
2022-07-20 18:11:49 +02:00
networking.interfaces.ens19.ipv6.routes = [
{ address = "fd00:10:42::"; prefixLength = 48; via = "fd00:10:42:10::1"; }
];
networking.interfaces.ens19.ipv4.routes = [
{ address = "10.42.0.0"; prefixLength = 16; via = "10.42.10.1"; }
];
networking.wireguard = {
enable = true;
interfaces = {
wg0 = {
ips = [ "fe80::42:10:1/64" ];
privateKeyFile = "/var/src/secrets/wireguard/wg0";
allowedIPsAsRoutes = false;
peers = [{
publicKey = "Y++eB9SfU17zB4mJ/6AaN761tngXAyTNoVaPNKmuvls=";
allowedIPs = [ "::/0" ];
endpoint = "78.47.183.82:51876";
#endpoint = "gatekeeper.net.clerie.de:51876";
persistentKeepalive = 25;
}];
};
};
};
networking.localCommands = ''
ip -6 route add default dev wg0 table 100
'';
clerie.policyrouting.enable = true;
clerie.policyrouting.rules6 = [
{ rule = "lookup main suppress_prefixlength 0"; prio = 10000; }
{ rule = "from 2a01:4f8:1c0c:8221::/64 lookup 100"; prio = 19000; }
];
2022-07-07 11:15:52 +02:00
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.11"; # Did you read the comment?
}