fix dns
This commit is contained in:
@@ -1,46 +1,48 @@
|
|||||||
{config, lib, ...}:
|
{ config, lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let cfg = config.custom.static-ip;
|
||||||
cfg = config.custom.static-ip;
|
in {
|
||||||
in
|
options.custom.static-ip = {
|
||||||
{
|
enable = mkEnableOption "Enables static-ip";
|
||||||
options.custom.static-ip = {
|
ip = lib.mkOption {
|
||||||
enable = mkEnableOption "Enables static-ip";
|
type = types.str;
|
||||||
ip = lib.mkOption {
|
description = "ipv4 address";
|
||||||
type = types.str;
|
};
|
||||||
description = "ipv4 address";
|
dns = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "ip of the dns server";
|
||||||
|
};
|
||||||
|
interface = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "interface to apply the change to";
|
||||||
|
};
|
||||||
|
gateway = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "192.168.0.1";
|
||||||
|
description = "Default gateway";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = let fallback = "1.1.1.1";
|
||||||
|
in mkIf cfg.enable {
|
||||||
|
networking = {
|
||||||
|
defaultGateway = cfg.gateway;
|
||||||
|
useDHCP = false;
|
||||||
|
nameservers = [ cfg.dns ]
|
||||||
|
++ lib.lists.optionals (!config.services.resolved.enable) [ fallback ];
|
||||||
|
interfaces = {
|
||||||
|
${cfg.interface} = {
|
||||||
|
name = "eth0";
|
||||||
|
ipv4.addresses = [{
|
||||||
|
address = cfg.ip;
|
||||||
|
prefixLength = 24;
|
||||||
|
}];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
dns = lib.mkOption {
|
};
|
||||||
type = types.str;
|
|
||||||
description = "ip of the dns server";
|
services.resolved = lib.mkIf config.services.resolved.enable {
|
||||||
};
|
llmnr = "false";
|
||||||
interface = lib.mkOption {
|
fallbackDns = [ "1.1.1.1" ];
|
||||||
type = types.str;
|
};
|
||||||
description = "interface to apply the change to";
|
|
||||||
};
|
|
||||||
gateway = lib.mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "192.168.0.1";
|
|
||||||
description = "Default gateway";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
networking = {
|
|
||||||
defaultGateway = cfg.gateway;
|
|
||||||
useDHCP = false;
|
|
||||||
nameservers = [
|
|
||||||
cfg.dns
|
|
||||||
"1.1.1.1"
|
|
||||||
];
|
|
||||||
interfaces = {
|
|
||||||
${cfg.interface} = {
|
|
||||||
name = "eth0";
|
|
||||||
ipv4.addresses = [{
|
|
||||||
address = cfg.ip;
|
|
||||||
prefixLength = 24;
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,9 @@
|
|||||||
interface = "enp42s0";
|
interface = "enp42s0";
|
||||||
ip = "192.168.0.11";
|
ip = "192.168.0.11";
|
||||||
#dns = "127.0.0.1";
|
#dns = "127.0.0.1";
|
||||||
dns = "192.168.10";
|
dns = "192.168.0.10";
|
||||||
#gateway = "192.168.0.10";
|
#gateway = "192.168.0.10";
|
||||||
};
|
};
|
||||||
# It uses 1.1.1.1 for some reason? set in /etc/dnsmasq-resolv.conf. no idea why
|
|
||||||
#services.dnsmasq = {
|
|
||||||
# enable = true;
|
|
||||||
# server = [ "192.168.0.10" ];
|
|
||||||
#};
|
|
||||||
misc = { docker.enable = true; };
|
misc = { docker.enable = true; };
|
||||||
services = { syncthing = { enable = true; }; };
|
services = { syncthing = { enable = true; }; };
|
||||||
hardware = {
|
hardware = {
|
||||||
|
|||||||
Reference in New Issue
Block a user