fix(pbx): ipv4 config

This commit is contained in:
arcnmx 2024-05-13 10:43:45 -07:00
parent 767247cc91
commit f826d2bb4a
6 changed files with 36 additions and 10 deletions

View file

@ -83,7 +83,7 @@
"networks": { "networks": {
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": "10.1.1.43",
"address6": "fd0a::be24:11ff:fe33:1904", "address6": "fd0a::be24:11ff:fe33:1904",
"macAddress": "BC:24:11:33:19:04" "macAddress": "BC:24:11:33:19:04"
}, },

View file

@ -46,6 +46,7 @@
moduleArgAttrs = let moduleArgAttrs = let
mkGetAddressFor = nameAllowed: addressForAttr: hostName: network: let mkGetAddressFor = nameAllowed: addressForAttr: hostName: network: let
forSystem = access.systemFor hostName; 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}"; err = throw "no interface found between ${config.networking.hostName} -> ${hostName}@${network}";
fallback = if nameAllowed fallback = if nameAllowed
then lib.warn "getAddressFor hostname fallback for ${config.networking.hostName} -> ${hostName}@${network}" (access.getHostnameFor hostName network) then lib.warn "getAddressFor hostname fallback for ${config.networking.hostName} -> ${hostName}@${network}" (access.getHostnameFor hostName network)
@ -56,8 +57,8 @@
in { in {
lan = lan =
if hostName == system.name then forSystem.access.${addressForAttr}.localhost if hostName == system.name then forSystem.access.${addressForAttr}.localhost
else if has'Int then int else if has'Int && forSystemHas "int" then int
else if has'Local then local else if has'Local && forSystemHas "local" then local
else fallback; else fallback;
${if has'Local then "local" else null} = local; ${if has'Local then "local" else null} = local;
${if has'Int then "int" else null} = int; ${if has'Int then "int" else null} = int;
@ -89,12 +90,12 @@
getAddress6For = mkGetAddressFor false "address6ForNetwork"; getAddress6For = mkGetAddressFor false "address6ForNetwork";
getHostnameFor = hostName: network: let getHostnameFor = hostName: network: let
forSystem = access.systemFor hostName; 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 { in {
lan = lan =
if hostName == system.name then forSystem.access.hostnameForNetwork.localhost 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'Int && forSystem.access.hostnameForNetwork ? int then forSystem.access.hostnameForNetwork.int
else if has'Local then forSystem.access.hostnameForNetwork.local or err else if has'Local && forSystem.access.hostnameForNetwork ? local then forSystem.access.hostnameForNetwork.local
else err; else err;
${if has'Local then "local" else null} = forSystem.access.hostnameForNetwork.local or 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; ${if has'Int then "int" else null} = forSystem.access.hostnameForNetwork.int or err;

View file

@ -14,7 +14,7 @@ in {
virtualHosts = let virtualHosts = let
proxyScheme = "https"; proxyScheme = "https";
url = access.proxyUrlFor { serviceName = "freepbx"; portName = proxyScheme; }; 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"; ucpPath = "/socket.io";
# TODO: ports.asterisk/asterisk-ssl? # TODO: ports.asterisk/asterisk-ssl?
extraConfig = '' extraConfig = ''

View file

@ -7,13 +7,19 @@ _: {
}; };
network.interfaces = { network.interfaces = {
net0 = { net0 = {
name = "ens18"; name = "eth0";
macAddress = "BC:24:11:33:19:04"; macAddress = "BC:24:11:33:19:04";
address4 = "dhcp"; address4 = "10.1.1.43";
address6 = "auto"; address6 = "auto";
}; };
}; };
}; };
extern.files = {
"/etc/sysconfig/network-scripts/ifcfg-eth0" = {
source = ./ifcfg-eth0;
mode = "0644";
};
};
exports = { exports = {
services = { services = {
sshd = { sshd = {

View file

@ -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"

View file

@ -45,7 +45,7 @@
"networks": { "networks": {
"int": null, "int": null,
"local": { "local": {
"address4": null, "address4": "10.1.1.43",
"address6": "fd0a::be24:11ff:fe33:1904", "address6": "fd0a::be24:11ff:fe33:1904",
"macAddress": "BC:24:11:33:19:04" "macAddress": "BC:24:11:33:19:04"
}, },