forked from DGNum/infrastructure
fix(network): Add dns servers on the main interface
This commit is contained in:
parent
18030d22e8
commit
b338eeed6a
1 changed files with 26 additions and 10 deletions
|
@ -1,16 +1,18 @@
|
|||
{ config, lib, meta, name, ... }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mapAttrs'
|
||||
mkEnableOption
|
||||
mkIf
|
||||
optionalAttrs;
|
||||
inherit (lib) mapAttrs' mkEnableOption mkIf optionalAttrs;
|
||||
|
||||
net = meta.network.${name};
|
||||
|
||||
mkAddress = { address, prefixLength, ... }: "${address}/${builtins.toString prefixLength}";
|
||||
mkRoute = gateway: { routeConfig = { Gateway = gateway; GatewayOnLink = true; }; };
|
||||
mkAddress = { address, prefixLength, ... }:
|
||||
"${address}/${builtins.toString prefixLength}";
|
||||
mkRoute = gateway: {
|
||||
routeConfig = {
|
||||
Gateway = gateway;
|
||||
GatewayOnLink = true;
|
||||
};
|
||||
};
|
||||
|
||||
mkInterface = interface: net: {
|
||||
name = "10-${interface}";
|
||||
|
@ -19,15 +21,29 @@ let
|
|||
address = builtins.map mkAddress (net.ipv4 ++ net.ipv6);
|
||||
routes = builtins.map mkRoute net.gateways;
|
||||
|
||||
# Add default DNS servers
|
||||
dns = [
|
||||
"1.1.1.1#cloudflare-dns.com"
|
||||
"8.8.8.8#dns.google"
|
||||
"1.0.0.1#cloudflare-dns.com"
|
||||
"8.8.4.4#dns.google"
|
||||
"[2606:4700:4700::1111]#cloudflare-dns.com"
|
||||
"[2001:4860:4860::8888]#dns.google"
|
||||
"[2606:4700:4700::1001]#cloudflare-dns.com"
|
||||
"[2001:4860:4860::8844]#dns.google"
|
||||
];
|
||||
|
||||
networkConfig = optionalAttrs (net ? DHCP) { inherit (net) DHCP; };
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.dgn-network;
|
||||
in
|
||||
|
||||
{
|
||||
options.dgn-network.enable = mkEnableOption "automatic network configuration based on metadata" // { default = true; };
|
||||
in {
|
||||
options.dgn-network.enable =
|
||||
mkEnableOption "automatic network configuration based on metadata" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking = {
|
||||
|
|
Loading…
Reference in a new issue