Création de la config de base WireGuard

This commit is contained in:
nyanloutre 2024-11-08 11:04:12 +01:00
parent fae42bcdb2
commit ae8d689727

View File

@ -1,7 +1,3 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, inputs, ... }:
{
@ -59,6 +55,11 @@
useNetworkd = true;
useDHCP = false;
nameservers = [
"1.1.1.1"
"1.0.0.1"
];
vlans = {
bouygues = {
id = 100;
@ -133,7 +134,30 @@
};
};
systemd.network.networks = {
systemd.network = {
enable = true;
netdevs = {
"10-wg0" = {
netdevConfig = {
Kind = "wireguard";
Name = "wg0";
};
wireguardConfig = {
PrivateKeyFile = "/run/keys/wireguard-privkey";
ListenPort = 9918;
};
wireguardPeers = [
{
PublicKey = "OhApdFoOYnKesRVpnYRqwk3pdM247j8PPVH5K7aIKX0=";
AllowedIPs = ["fc00::1/64" "10.100.0.1"];
Endpoint = "{set this to the server ip}:51820";
}
];
};
};
networks = {
"40-bouygues" = {
dhcpV4Config.RouteMetric = 1;
dhcpV6Config = {
@ -149,6 +173,14 @@
dhcpPrefixDelegationConfig.SubnetId = "0";
};
"40-eno1".linkConfig.RequiredForOnline = "no";
"10-wg0" = {
matchConfig.Name = "wg0";
address = [
"fe80::3/64"
"fc00::3/120"
"10.100.0.2/24"
];
};
"40-eno2" = {
networkConfig = {
IPv6SendRA = true;
@ -212,8 +244,10 @@
];
};
};
# Set 4G connection as low routing priority
"40-enp0s21u1".dhcpV4Config.RouteMetric = 1024;
};
};
services.openssh = {
enable = true;