From f826d2bb4a320c239d7ad938a78c15c0bf7716f0 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Mon, 13 May 2024 10:43:45 -0700 Subject: [PATCH] fix(pbx): ipv4 config --- ci/systems.json | 2 +- modules/system/access.nix | 11 ++++++----- nixos/access/freepbx.nix | 2 +- systems/freepbx/default.nix | 10 ++++++++-- systems/freepbx/ifcfg-eth0 | 19 +++++++++++++++++++ systems/reisen/systems.json | 2 +- 6 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 systems/freepbx/ifcfg-eth0 diff --git a/ci/systems.json b/ci/systems.json index 8ba93330..9956adcf 100644 --- a/ci/systems.json +++ b/ci/systems.json @@ -83,7 +83,7 @@ "networks": { "int": null, "local": { - "address4": null, + "address4": "10.1.1.43", "address6": "fd0a::be24:11ff:fe33:1904", "macAddress": "BC:24:11:33:19:04" }, diff --git a/modules/system/access.nix b/modules/system/access.nix index 30521a2f..9503ef38 100644 --- a/modules/system/access.nix +++ b/modules/system/access.nix @@ -46,6 +46,7 @@ moduleArgAttrs = let mkGetAddressFor = nameAllowed: addressForAttr: hostName: network: let forSystem = access.systemFor hostName; + forSystemHas = network: forSystem.access ? ${addressForAttr}.${network} || forSystem.access ? address4ForNetwork.${network}; err = throw "no interface found between ${config.networking.hostName} -> ${hostName}@${network}"; fallback = if nameAllowed then lib.warn "getAddressFor hostname fallback for ${config.networking.hostName} -> ${hostName}@${network}" (access.getHostnameFor hostName network) @@ -56,8 +57,8 @@ in { lan = if hostName == system.name then forSystem.access.${addressForAttr}.localhost - else if has'Int then int - else if has'Local then local + else if has'Int && forSystemHas "int" then int + else if has'Local && forSystemHas "local" then local else fallback; ${if has'Local then "local" else null} = local; ${if has'Int then "int" else null} = int; @@ -89,12 +90,12 @@ getAddress6For = mkGetAddressFor false "address6ForNetwork"; getHostnameFor = hostName: network: let forSystem = access.systemFor hostName; - err = throw "no ${network} interface found between ${config.networking.hostName} and ${hostName}"; + err = throw "no hostname found between ${config.networking.hostName} and ${hostName}@${network}"; in { lan = if hostName == system.name then forSystem.access.hostnameForNetwork.localhost - else if has'Int then forSystem.access.hostnameForNetwork.int or forSystem.access.hostnameForNetwork.local or err - else if has'Local then forSystem.access.hostnameForNetwork.local or err + else if has'Int && forSystem.access.hostnameForNetwork ? int then forSystem.access.hostnameForNetwork.int + else if has'Local && forSystem.access.hostnameForNetwork ? local then forSystem.access.hostnameForNetwork.local else err; ${if has'Local then "local" else null} = forSystem.access.hostnameForNetwork.local or err; ${if has'Int then "int" else null} = forSystem.access.hostnameForNetwork.int or err; diff --git a/nixos/access/freepbx.nix b/nixos/access/freepbx.nix index dc6629a2..76b1f012 100644 --- a/nixos/access/freepbx.nix +++ b/nixos/access/freepbx.nix @@ -14,7 +14,7 @@ in { virtualHosts = let proxyScheme = "https"; url = access.proxyUrlFor { serviceName = "freepbx"; portName = proxyScheme; }; - ucpUrl = access.proxyUrlFor { serviceName = "freepbx"; portName = "ucp-ssl"; }; + ucpUrl = access.proxyUrlFor { serviceName = "freepbx"; portName = "ucp-ssl"; getAddressFor = "getAddress4For"; }; ucpPath = "/socket.io"; # TODO: ports.asterisk/asterisk-ssl? extraConfig = '' diff --git a/systems/freepbx/default.nix b/systems/freepbx/default.nix index fb17c1b0..9e17e011 100644 --- a/systems/freepbx/default.nix +++ b/systems/freepbx/default.nix @@ -7,13 +7,19 @@ _: { }; network.interfaces = { net0 = { - name = "ens18"; + name = "eth0"; macAddress = "BC:24:11:33:19:04"; - address4 = "dhcp"; + address4 = "10.1.1.43"; address6 = "auto"; }; }; }; + extern.files = { + "/etc/sysconfig/network-scripts/ifcfg-eth0" = { + source = ./ifcfg-eth0; + mode = "0644"; + }; + }; exports = { services = { sshd = { diff --git a/systems/freepbx/ifcfg-eth0 b/systems/freepbx/ifcfg-eth0 new file mode 100644 index 00000000..d3776651 --- /dev/null +++ b/systems/freepbx/ifcfg-eth0 @@ -0,0 +1,19 @@ +TYPE="Ethernet" +PROXY_METHOD="none" +BROWSER_ONLY="no" +DEFROUTE="yes" +IPV4_FAILURE_FATAL="no" +IPV6INIT="yes" +IPV6_AUTOCONF="yes" +IPV6_DEFROUTE="yes" +IPV6_FAILURE_FATAL="no" +IPV6_ADDR_GEN_MODE="stable-privacy" +NAME="eth0" +UUID="67f844cf-952d-486b-9788-1e4f7ae3119c" +DEVICE="eth0" +ONBOOT="yes" +#BOOTPROTO="dhcp" +BOOTPROTO="static" +IPADDR="10.1.1.43" +GATEWAY="10.1.1.1" +NETMASK="255.255.255.0" diff --git a/systems/reisen/systems.json b/systems/reisen/systems.json index ff89fdb6..09ef302d 100644 --- a/systems/reisen/systems.json +++ b/systems/reisen/systems.json @@ -45,7 +45,7 @@ "networks": { "int": null, "local": { - "address4": null, + "address4": "10.1.1.43", "address6": "fd0a::be24:11ff:fe33:1904", "macAddress": "BC:24:11:33:19:04" },