Skip to content

Commit

Permalink
examples/microvms-host: hand out IP addresses to all nested vms
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Mar 21, 2024
1 parent 30e8266 commit a8678ad
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions examples/microvms-host.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,26 @@ nixpkgs.lib.nixosSystem {
};
networks.virbr0 = {
matchConfig.Name = "virbr0";

addresses = [ {
addressConfig.Address = "10.0.0.1/24";
} {
addressConfig.Address = "fd12:3456:789a::1/64";
} ];
# Hand out IP addresses to MicroVMs.
# Use `networkctl status virbr0` to see leases.
networkConfig = {
DHCPServer = true;
IPv6SendRA = true;
};
dhcpServerStaticLeases = [ {
# Let DHCP assign a statically known address to the qemu vm
# Let DHCP assign a statically known address to the VMs
dhcpServerStaticLeases = lib.imap0 (i: hypervisor: {
dhcpServerStaticLeaseConfig = {
MACAddress = hypervisors-with-mac.qemu;
Address = "10.0.13.37";
MACAddress = hypervisorMacAddrs.${hypervisor};
Address = "10.0.0.${toString (2 + i)}";
};
} ];
addresses = [ {
addressConfig.Address = "10.0.0.1/24";
} {
addressConfig.Address = "fd12:3456:789a::1/64";
} ];
}) (builtins.attrNames hypervisorMacAddrs);
# IPv6 SLAAC
ipv6Prefixes = [ {
ipv6PrefixConfig.Prefix = "fd12:3456:789a::/64";
} ];
Expand Down

0 comments on commit a8678ad

Please sign in to comment.