···1212follows:
13131414<programlisting>
1515-networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ];
1515+networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; };
1616</programlisting>
17171818+(The network prefix can also be specified using the option
1919+<literal>subnetMask</literal>,
2020+e.g. <literal>"255.255.255.0"</literal>, but this is deprecated.)
1821Typically you’ll also want to set a default gateway and set of name
1922servers:
2023
+5-6
nixos/lib/build-vms.nix
···4848 let
4949 interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
5050 interfaces = flip map interfacesNumbered ({ first, second }:
5151- nameValuePair "eth${toString second}" { ip4 =
5252- [ { address = "192.168.${toString first}.${toString m.second}";
5353- prefixLength = 24;
5454- } ];
5555- }
5151+ nameValuePair "eth${toString second}"
5252+ { ipAddress = "192.168.${toString first}.${toString m.second}";
5353+ subnetMask = "255.255.255.0";
5454+ });
5655 in
5756 { key = "ip-address";
5857 config =
···6160 networking.interfaces = listToAttrs interfaces;
62616362 networking.primaryIPAddress =
6464- optionalString (interfaces != []) (head (head interfaces).value.ip4).address;
6363+ optionalString (interfaces != []) (head interfaces).value.ipAddress;
65646665 # Put the IP addresses of all VMs in this machine's
6766 # /etc/hosts file. If a machine has multiple