Skip to content

Commit a8678ad

Browse files
committed
examples/microvms-host: hand out IP addresses to all nested vms
1 parent 30e8266 commit a8678ad

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples/microvms-host.nix

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,26 @@ nixpkgs.lib.nixosSystem {
8282
};
8383
networks.virbr0 = {
8484
matchConfig.Name = "virbr0";
85+
86+
addresses = [ {
87+
addressConfig.Address = "10.0.0.1/24";
88+
} {
89+
addressConfig.Address = "fd12:3456:789a::1/64";
90+
} ];
8591
# Hand out IP addresses to MicroVMs.
8692
# Use `networkctl status virbr0` to see leases.
8793
networkConfig = {
8894
DHCPServer = true;
8995
IPv6SendRA = true;
9096
};
91-
dhcpServerStaticLeases = [ {
92-
# Let DHCP assign a statically known address to the qemu vm
97+
# Let DHCP assign a statically known address to the VMs
98+
dhcpServerStaticLeases = lib.imap0 (i: hypervisor: {
9399
dhcpServerStaticLeaseConfig = {
94-
MACAddress = hypervisors-with-mac.qemu;
95-
Address = "10.0.13.37";
100+
MACAddress = hypervisorMacAddrs.${hypervisor};
101+
Address = "10.0.0.${toString (2 + i)}";
96102
};
97-
} ];
98-
addresses = [ {
99-
addressConfig.Address = "10.0.0.1/24";
100-
} {
101-
addressConfig.Address = "fd12:3456:789a::1/64";
102-
} ];
103+
}) (builtins.attrNames hypervisorMacAddrs);
104+
# IPv6 SLAAC
103105
ipv6Prefixes = [ {
104106
ipv6PrefixConfig.Prefix = "fd12:3456:789a::/64";
105107
} ];

0 commit comments

Comments
 (0)