NixOS/hosts/luna/modules/networking.nix

97 lines
2.3 KiB
Nix
Raw Normal View History

2023-10-27 01:46:14 -05:00
{ inputs, lib, pkgs, hostname, ... }:
let
hostname = "luna";
networks_dhcp_use_dns = "no";
2023-10-27 23:02:52 -05:00
networks_dhcp = "ipv4";
networks_multicast_dns = "no";
2023-10-27 01:46:14 -05:00
networks_ipv6_privacy = "yes";
networks_ipv6_accept_ra = "yes";
networks_network_config = {
DHCP = networks_dhcp;
MulticastDNS = networks_multicast_dns;
IPv6PrivacyExtensions = networks_ipv6_privacy;
IPv6AcceptRA = networks_ipv6_accept_ra;
};
resolved_nameservers = [
"1.1.1.1#cloudflare-dns.com"
"9.9.9.9#dns.quad9.net"
"8.8.8.8#dns.google"
"2606:4700:4700::1111#cloudflare-dns.com"
"2620:fe::9#dns.quad9.net"
"2001:4860:4860::8888#dns.google"
];
resolved_fallback_nameservers = [ "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ];
in
{
systemd.network = {
enable = true;
networks = {
"10-wlan" = {
matchConfig.Name = [ "wl*" ];
networkConfig = networks_network_config;
dhcpV4Config = {
RouteMetric = 600;
UseDNS = networks_dhcp_use_dns;
};
ipv6AcceptRAConfig = {
RouteMetric = 600;
UseDNS = networks_dhcp_use_dns;
};
};
"10-ethernet" = {
2023-10-27 23:02:52 -05:00
matchConfig.Name = [ "en*" "eth*" ];
2023-10-27 01:46:14 -05:00
networkConfig = networks_network_config;
dhcpV4Config = {
RouteMetric = 100;
UseDNS = networks_dhcp_use_dns;
};
ipv6AcceptRAConfig = {
RouteMetric = 100;
UseDNS = networks_dhcp_use_dns;
};
};
"10-wwan" = {
2023-10-27 23:02:52 -05:00
matchConfig.Name = [ "ww*" ];
2023-10-27 01:46:14 -05:00
networkConfig = networks_network_config;
dhcpV4Config = {
RouteMetric = 700;
UseDNS = networks_dhcp_use_dns;
};
ipv6AcceptRAConfig = {
RouteMetric = 700;
UseDNS = networks_dhcp_use_dns;
};
};
};
};
services.resolved = {
enable = true;
dnssec = "allow-downgrade";
2023-10-27 23:02:52 -05:00
domains = [ "~." ];
2023-10-27 01:46:14 -05:00
fallbackDns = resolved_fallback_nameservers;
llmnr = "resolve";
2023-10-27 01:46:14 -05:00
extraConfig = ''
MulticastDNS=yes
DNSOverTLS=yes
CacheFromLocalhost=no
Cache=yes
'';
};
networking = {
2023-10-27 23:02:52 -05:00
nameservers = resolved_nameservers;
nftables.enable = true;
firewall = {
enable = true;
allowedTCPPorts = [
80
443
2200
];
};
2023-10-27 01:46:14 -05:00
hostName = "${hostname}";
};
}