feat: schizo networking
This commit is contained in:
parent
92bb3f929b
commit
c5898e58d0
5 changed files with 116 additions and 42 deletions
|
@ -15,11 +15,6 @@
|
||||||
fstrim.enable = lib.mkDefault true;
|
fstrim.enable = lib.mkDefault true;
|
||||||
thermald.enable = true;
|
thermald.enable = true;
|
||||||
printing.enable = true;
|
printing.enable = true;
|
||||||
avahi = {
|
|
||||||
enable = true;
|
|
||||||
nssmdns4 = true;
|
|
||||||
openFirewall = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
virtualisation.docker.enable = true;
|
virtualisation.docker.enable = true;
|
||||||
|
|
||||||
|
|
55
modules/system/os/networking/dns.nix
Normal file
55
modules/system/os/networking/dns.nix
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
StateDirectory = "dnscrypt-proxy";
|
||||||
|
inherit (lib.modules) mkForce;
|
||||||
|
in {
|
||||||
|
networking = {
|
||||||
|
networkmanager.dns = mkForce "none";
|
||||||
|
nameservers = [
|
||||||
|
"127.0.0.1"
|
||||||
|
"::1"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# See https://wiki.nixos.org/wiki/Encrypted_DNS
|
||||||
|
services.dnscrypt-proxy2 = {
|
||||||
|
enable = true;
|
||||||
|
# See https://github.com/DNSCrypt/dnscrypt-proxy/blob/master/dnscrypt-proxy/example-dnscrypt-proxy.toml
|
||||||
|
settings = {
|
||||||
|
sources.public-resolvers = {
|
||||||
|
urls = [
|
||||||
|
"https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md"
|
||||||
|
"https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md"
|
||||||
|
];
|
||||||
|
minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3"; # See https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md
|
||||||
|
cache_file = "/var/lib/${StateDirectory}/public-resolvers.md";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Use servers reachable over IPv6 -- Do not enable if you don't have IPv6 connectivity
|
||||||
|
ipv6_servers = true;
|
||||||
|
|
||||||
|
# Server must support DNS security extensions (DNSSEC)
|
||||||
|
require_dnssec = true;
|
||||||
|
|
||||||
|
# Server must not log user queries (declarative)
|
||||||
|
require_nolog = true;
|
||||||
|
|
||||||
|
# Server must not enforce its own blocklist (for parental control, ads blocking...)
|
||||||
|
require_nofilter = true;
|
||||||
|
|
||||||
|
## Enable *experimental* support for HTTP/3 (DoH3, HTTP over QUIC)
|
||||||
|
## Note that, like DNSCrypt but unlike other HTTP versions, this uses
|
||||||
|
## UDP and (usually) port 443 instead of TCP.
|
||||||
|
http3 = false;
|
||||||
|
|
||||||
|
## Enable a DNS cache to reduce latency and outgoing traffic.
|
||||||
|
cache = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.dnscrypt-proxy2.serviceConfig.StateDirectory = StateDirectory;
|
||||||
|
}
|
18
modules/system/os/networking/firewall.nix
Normal file
18
modules/system/os/networking/firewall.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
in {
|
||||||
|
networking = {
|
||||||
|
# use nftables over iptables
|
||||||
|
nftables.enable = true;
|
||||||
|
|
||||||
|
firewall = {
|
||||||
|
enable = true;
|
||||||
|
allowPing = false;
|
||||||
|
logReversePathDrops = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,43 +3,55 @@
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./networkmanager.nix
|
./networkmanager.nix
|
||||||
|
./dns.nix
|
||||||
|
./firewall.nix
|
||||||
];
|
];
|
||||||
networking = {
|
networking = {
|
||||||
enableIPv6 = true;
|
enableIPv6 = true;
|
||||||
|
|
||||||
# INFO: This disables wpa_supplicant,
|
wireless = {
|
||||||
# I use nenetworkmanager instead.
|
# INFO: This disables wpa_supplicant,
|
||||||
wireless.enable = false;
|
# I use iwd instead.
|
||||||
|
enable = false;
|
||||||
|
|
||||||
|
# use iwd over wpa_supplicant
|
||||||
|
iwd = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
IPv6 = {
|
||||||
|
Enabled = true;
|
||||||
|
};
|
||||||
|
Settings = {
|
||||||
|
AutoConnect = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
dhcpcd = {
|
dhcpcd = {
|
||||||
# faster boot times
|
# faster boot times
|
||||||
wait = "background";
|
wait = "background";
|
||||||
extraConfig = "noarp";
|
# do not edit resolv.conf
|
||||||
|
extraConfig = ''
|
||||||
|
nohook resolv.conf
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
nameservers = [
|
# service discovery on a local network via the mDNS/DNS-SD protocol suite
|
||||||
# I have choosen Mullvad DNS as my standard DNS provider,
|
services.avahi = {
|
||||||
# as Quad9 at some point stopped resolving my universitie's IP address.
|
|
||||||
# Furthermore, Mullvad has a pretty good reputation when it comes to privacy
|
|
||||||
"194.242.2.4"
|
|
||||||
"2a07:e340::4"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
services.resolved = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
dnssec = "false";
|
nssmdns4 = true;
|
||||||
dnsovertls = "opportunistic";
|
openFirewall = true;
|
||||||
fallbackDns = [
|
|
||||||
"194.242.2.4"
|
|
||||||
"2a07:e340::4"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.${username}.extraGroups = ["networkmanager"];
|
users.users.${username}.extraGroups = ["networkmanager"];
|
||||||
|
|
||||||
# systemd = {
|
# faster boot
|
||||||
# network = {
|
systemd = {
|
||||||
# enable = true;
|
network = {
|
||||||
# wait-online.anyInterface = true;
|
enable = true;
|
||||||
# };
|
wait-online.enable = false;
|
||||||
# };
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
{lib, ...}: let
|
_: {
|
||||||
inherit (lib.modules) mkForce;
|
|
||||||
in {
|
|
||||||
networking.networkmanager = {
|
networking.networkmanager = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# # Removes about 2GB of stuff we do no need.
|
|
||||||
# plugins = mkForce [];
|
|
||||||
|
|
||||||
dns = "systemd-resolved";
|
|
||||||
unmanaged = [
|
|
||||||
# DO NOT manage my docker containers, thank you.
|
|
||||||
"interface-name:docker*"
|
|
||||||
];
|
|
||||||
wifi = {
|
wifi = {
|
||||||
# Generate a randomized value upon each connect
|
# Generate a randomized value upon each connect
|
||||||
macAddress = "random";
|
macAddress = "random";
|
||||||
|
@ -19,8 +10,11 @@ in {
|
||||||
powersave = true;
|
powersave = true;
|
||||||
|
|
||||||
# Backend is either wpa_supplicant or iwd,
|
# Backend is either wpa_supplicant or iwd,
|
||||||
# I use wpa_supplicant since it is simply more reliable.
|
# I use iwd.
|
||||||
backend = "wpa_supplicant";
|
backend = "iwd";
|
||||||
|
|
||||||
|
# Whether to enable MAC address randomization of a Wi-Fi device during scanning.
|
||||||
|
scanRandMacAddress = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue