2024-01-15 01:12:09 +00:00
|
|
|
{ lib, ... }:
|
2022-08-31 04:56:04 +00:00
|
|
|
|
|
|
|
{
|
2024-01-15 01:11:13 +00:00
|
|
|
imports = [
|
2024-01-15 01:16:22 +00:00
|
|
|
./dns.nix
|
2024-01-15 01:11:13 +00:00
|
|
|
./hostnames.nix
|
2024-01-15 01:12:09 +00:00
|
|
|
./upnp.nix
|
2024-01-15 01:11:13 +00:00
|
|
|
./vpn.nix
|
|
|
|
];
|
2024-01-16 03:20:40 +00:00
|
|
|
|
|
|
|
systemd.network.enable = true;
|
|
|
|
networking.useNetworkd = true;
|
|
|
|
|
2024-01-19 09:54:01 +00:00
|
|
|
# view refused/dropped packets with: `sudo journalctl -k`
|
2024-01-16 03:20:40 +00:00
|
|
|
# networking.firewall.logRefusedPackets = true;
|
|
|
|
# networking.firewall.logRefusedUnicastsOnly = false;
|
2024-01-19 09:54:01 +00:00
|
|
|
networking.firewall.logReversePathDrops = true;
|
|
|
|
# linux will drop inbound packets if it thinks a reply to that packet wouldn't exit via the same interface (rpfilter).
|
|
|
|
# that heuristic fails for complicated VPN-style routing, especially with SNAT.
|
|
|
|
# networking.firewall.checkReversePath = false; # or "loose" to keep it partially.
|
2024-01-16 03:20:40 +00:00
|
|
|
# networking.firewall.enable = false; #< set false to debug
|
|
|
|
|
2024-01-19 21:34:18 +00:00
|
|
|
# this is needed to forward packets from the VPN to the host.
|
|
|
|
# this is required separately by servo and by any `sane-vpn` users,
|
|
|
|
# however Nix requires this be set centrally, in only one location (i.e. here)
|
|
|
|
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
|
|
|
|
|
2022-09-28 12:25:34 +00:00
|
|
|
# the default backend is "wpa_supplicant".
|
|
|
|
# wpa_supplicant reliably picks weak APs to connect to.
|
|
|
|
# see: <https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/474>
|
2022-09-29 10:33:48 +00:00
|
|
|
# iwd is an alternative that shouldn't have this problem
|
|
|
|
# docs:
|
|
|
|
# - <https://nixos.wiki/wiki/Iwd>
|
|
|
|
# - <https://iwd.wiki.kernel.org/networkmanager>
|
2022-10-24 07:25:19 +00:00
|
|
|
# - `man iwd.config` for global config
|
|
|
|
# - `man iwd.network` for per-SSID config
|
2022-09-29 10:33:48 +00:00
|
|
|
# use `iwctl` to control
|
2023-07-15 06:58:32 +00:00
|
|
|
# networking.networkmanager.wifi.backend = "iwd";
|
|
|
|
# networking.wireless.iwd.enable = true;
|
|
|
|
# networking.wireless.iwd.settings = {
|
|
|
|
# # auto-connect to a stronger network if signal drops below this value
|
|
|
|
# # bedroom -> bedroom connection is -35 to -40 dBm
|
|
|
|
# # bedroom -> living room connection is -60 dBm
|
|
|
|
# General.RoamThreshold = "-52"; # default -70
|
|
|
|
# General.RoamThreshold5G = "-52"; # default -76
|
|
|
|
# };
|
2023-05-26 22:45:41 +00:00
|
|
|
|
2023-06-29 10:58:18 +00:00
|
|
|
# plugins mostly add support for establishing different VPN connections.
|
|
|
|
# the default plugin set includes mostly proprietary VPNs:
|
|
|
|
# - fortisslvpn (Fortinet)
|
|
|
|
# - iodine (DNS tunnels)
|
|
|
|
# - l2tp
|
|
|
|
# - openconnect (Cisco Anyconnect / Juniper / ocserv)
|
|
|
|
# - openvpn
|
|
|
|
# - vpnc (Cisco VPN)
|
|
|
|
# - sstp
|
|
|
|
#
|
|
|
|
# i don't use these, and notably they drag in huge dependency sets and don't cross compile well.
|
|
|
|
# e.g. openconnect drags in webkitgtk (for SSO)!
|
|
|
|
networking.networkmanager.plugins = lib.mkForce [];
|
|
|
|
|
2023-07-15 06:58:32 +00:00
|
|
|
# keyfile.path = where networkmanager should look for connection credentials
|
|
|
|
networking.networkmanager.extraConfig = ''
|
|
|
|
[keyfile]
|
|
|
|
path=/var/lib/NetworkManager/system-connections
|
|
|
|
'';
|
2022-08-31 04:56:04 +00:00
|
|
|
}
|