From 57f8e0e97463dec3e0da7f4b995ee89b92d36687 Mon Sep 17 00:00:00 2001 From: Matthew Salerno Date: Wed, 13 Sep 2023 18:38:42 -0400 Subject: [PATCH] Fixed manual ipv4 assignment issue --- configurers/networkd.nix | 4 ++-- configurers/static.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configurers/networkd.nix b/configurers/networkd.nix index 73ff735..216d1b7 100644 --- a/configurers/networkd.nix +++ b/configurers/networkd.nix @@ -20,7 +20,7 @@ in with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; { networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection: - forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${strings.removeSuffix "/64" ip} ${remotePeerName}.${subnetName}")) + forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${cidr2ip ip} ${remotePeerName}.${subnetName}")) )))); systemd.network = { netdevs = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "50-${shortName subnetName}" { @@ -37,7 +37,7 @@ with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; wireguardPeerConfig = { Endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}"; PublicKey = getPeerPubKey remotePeerName; - AllowedIPs = map (ip: cidr2ip ip + "/128") peerConnection.ipAddresses; + AllowedIPs = map (ip: cidr2ip ip + (if match ".*:.*" ip != null then "/128" else "/32")) peerConnection.ipAddresses; PresharedKeyFile = getSubnetPSKFile subnetName; }; } diff --git a/configurers/static.nix b/configurers/static.nix index e8e571d..afc659a 100644 --- a/configurers/static.nix +++ b/configurers/static.nix @@ -19,7 +19,7 @@ in with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; { networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection: - forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${strings.removeSuffix "/64" ip} ${remotePeerName}.${subnetName}")) + forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${cidr2ip ip} ${remotePeerName}.${subnetName}")) )))); networking.wireguard = { interfaces = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "${head (strings.splitString "." subnetName)}" @@ -32,7 +32,7 @@ with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; name = remotePeerName; publicKey = getPeerPubKey remotePeerName; presharedKeyFile = getSubnetPSKFile subnetName; - allowedIPs = map (ip: cidr2ip ip + "/128") peerConnection.ipAddresses; + allowedIPs = map ( ip: cidr2ip ip + (if match ".*:.*" ip != null then "/128" else "/32")) peerConnection.ipAddresses; endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}"; } // (mergeIf peerConnection.endpoint "persistentKeepalive")