Support static IP on externalInterface

This commit is contained in:
Jonas Juselius
2020-11-25 10:13:34 +01:00
parent e36126e429
commit 0ab907609c

View File

@@ -16,6 +16,27 @@ in
default = null; default = null;
}; };
address = mkOption {
type = types.nullOr types.str;
default = null;
};
externalInterface = mkOption {
type = types.nullOr types.str;
default = null;
};
defaultGateway = mkOption {
type = types.nullOr types.str;
default = null;
};
nameservers = mkOption {
type = types.listOf types.str;
default = [ "8.8.8.8" ];
};
domain = mkOption { domain = mkOption {
type = types.str; type = types.str;
default = null; default = null;
@@ -54,11 +75,28 @@ in
cfg.adminAuthorizedKeys; cfg.adminAuthorizedKeys;
networking = { networking = {
hostName = cfg.hostName;
domain = cfg.domain; domain = cfg.domain;
search = cfg.searchDomains; search = cfg.searchDomains;
extraHosts = cfg.extraHosts; extraHosts = cfg.extraHosts;
}; firewall.allowedTCPPortRanges = [ { from = 5000; to = 50000; } ];
firewall.allowedTCPPorts = [ 80 443 111 ];
firewall.allowedUDPPorts = [ 111 24007 24008 ];
} // (
if cfg.externalInterface == null then
{ hostName = cfg.hostName; }
else {
hostName = cfg.hostName;
interfaces."${cfg.externalInterface}" = {
useDHCP = false;
ipv4.addresses = [ {
address = cfg.address;
prefixLength = 24;
} ];
};
defaultGateway = cfg.defaultGateway;
nameservers = cfg.nameservers;
}
);
security.pki.certificateFiles = [ pki.ca.cert ]; security.pki.certificateFiles = [ pki.ca.cert ];
boot.kernel.sysctl = { boot.kernel.sysctl = {
@@ -66,12 +104,6 @@ in
"net.core.somaxconn" = "512"; "net.core.somaxconn" = "512";
}; };
networking = {
firewall.allowedTCPPortRanges = [ { from = 5000; to = 50000; } ];
firewall.allowedTCPPorts = [ 80 443 111 ];
firewall.allowedUDPPorts = [ 111 24007 24008 ];
};
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
nfs-utils nfs-utils
]; ];