diff options
-rw-r--r-- | accounts/gkleen@sif/zshrc | 17 | ||||
-rw-r--r-- | modules/yggdrasil-wg/default.nix | 18 |
2 files changed, 28 insertions, 7 deletions
diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 9fe88163..bcdc662a 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc | |||
@@ -399,6 +399,23 @@ ssh-installer() { | |||
399 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ | 399 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=~/.ssh/gkleen@sif.midgard.yggdrasil $@ |
400 | } | 400 | } |
401 | 401 | ||
402 | dichotomic_search() { | ||
403 | min=$1; shift | ||
404 | max=$1; shift | ||
405 | |||
406 | while [[ $min -lt $max ]]; do | ||
407 | # Compute the mean between min and max, rounded up to the superior unit | ||
408 | current=$(( (min + max + 1 ) / 2 )) | ||
409 | if $@ $current; then | ||
410 | min=$current | ||
411 | else | ||
412 | max=$((current - 1)) | ||
413 | fi | ||
414 | done | ||
415 | |||
416 | echo $min | ||
417 | } | ||
418 | |||
402 | alias '..'='cd ..' | 419 | alias '..'='cd ..' |
403 | alias -g L='| less' | 420 | alias -g L='| less' |
404 | alias -g S='&> /dev/null' | 421 | alias -g S='&> /dev/null' |
diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix index 316371ea..48672fcb 100644 --- a/modules/yggdrasil-wg/default.nix +++ b/modules/yggdrasil-wg/default.nix | |||
@@ -37,9 +37,14 @@ let | |||
37 | sif = "${wgSubnet}:2::/${toString wgHostLength}"; | 37 | sif = "${wgSubnet}:2::/${toString wgHostLength}"; |
38 | }; | 38 | }; |
39 | greHostMACPrefixes = { | 39 | greHostMACPrefixes = { |
40 | surtr = "02:00:00:00:00"; | 40 | surtr = "02:00:01:00:00"; |
41 | vidhar = "02:00:00:00:01"; | 41 | vidhar = "02:00:01:00:01"; |
42 | sif = "02:00:00:00:02"; | 42 | sif = "02:00:01:00:02"; |
43 | }; | ||
44 | batHostMACs = { | ||
45 | surtr = "02:00:00:00:00:00"; | ||
46 | vidhar = "02:00:00:01:00:00"; | ||
47 | sif = "02:00:00:02:00:00"; | ||
43 | }; | 48 | }; |
44 | batHostIPs = { | 49 | batHostIPs = { |
45 | surtr = ["${batSubnet}::/${toString batHostLength}"]; | 50 | surtr = ["${batSubnet}::/${toString batHostLength}"]; |
@@ -70,12 +75,10 @@ let | |||
70 | netdevConfig = { | 75 | netdevConfig = { |
71 | Name = "yggre-${other}"; | 76 | Name = "yggre-${other}"; |
72 | Kind = "ip6gretap"; | 77 | Kind = "ip6gretap"; |
73 | MTUBytes = toString (1280 + 58); | ||
74 | }; | 78 | }; |
75 | tunnelConfig = { | 79 | tunnelConfig = { |
76 | Local = stripSubnet wgHostIPs.${hostName}; | 80 | Local = stripSubnet wgHostIPs.${hostName}; |
77 | Remote = stripSubnet wgHostIPs.${other}; | 81 | Remote = stripSubnet wgHostIPs.${other}; |
78 | DiscoverPathMTU = false; | ||
79 | }; | 82 | }; |
80 | }; | 83 | }; |
81 | linkToGreNetwork = ix: opts@{from, to, ...}: | 84 | linkToGreNetwork = ix: opts@{from, to, ...}: |
@@ -123,7 +126,6 @@ in { | |||
123 | netdevConfig = { | 126 | netdevConfig = { |
124 | Name = "yggdrasil-wg"; | 127 | Name = "yggdrasil-wg"; |
125 | Kind = "wireguard"; | 128 | Kind = "wireguard"; |
126 | MTUBytes = toString (1280 + 58 + 70); | ||
127 | }; | 129 | }; |
128 | wireguardConfig = { | 130 | wireguardConfig = { |
129 | PrivateKeyFile = config.sops.secrets."yggdrasil-wg.priv".path; | 131 | PrivateKeyFile = config.sops.secrets."yggdrasil-wg.priv".path; |
@@ -135,7 +137,9 @@ in { | |||
135 | netdevConfig = { | 137 | netdevConfig = { |
136 | Name = "yggdrasil"; | 138 | Name = "yggdrasil"; |
137 | Kind = "batadv"; | 139 | Kind = "batadv"; |
138 | MTUBytes = toString 1280; | 140 | }; |
141 | linkConfig = { | ||
142 | MACAddress = "${batHostMACs.${hostName}}"; | ||
139 | }; | 143 | }; |
140 | }; | 144 | }; |
141 | } // listToAttrs (map linkToGreDev hostLinks); | 145 | } // listToAttrs (map linkToGreDev hostLinks); |