···12follows:
1314<programlisting>
15-networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ];
16</programlisting>
1700018Typically you’ll also want to set a default gateway and set of name
19servers:
20
···12follows:
1314<programlisting>
15+networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; };
16</programlisting>
1718+(The network prefix can also be specified using the option
19+<literal>subnetMask</literal>,
20+e.g. <literal>"255.255.255.0"</literal>, but this is deprecated.)
21Typically you’ll also want to set a default gateway and set of name
22servers:
23
+5-6
nixos/lib/build-vms.nix
···48 let
49 interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
50 interfaces = flip map interfacesNumbered ({ first, second }:
51- nameValuePair "eth${toString second}" { ip4 =
52- [ { address = "192.168.${toString first}.${toString m.second}";
53- prefixLength = 24;
54- } ];
55- }
56 in
57 { key = "ip-address";
58 config =
···61 networking.interfaces = listToAttrs interfaces;
6263 networking.primaryIPAddress =
64- optionalString (interfaces != []) (head (head interfaces).value.ip4).address;
6566 # Put the IP addresses of all VMs in this machine's
67 # /etc/hosts file. If a machine has multiple
···48 let
49 interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
50 interfaces = flip map interfacesNumbered ({ first, second }:
51+ nameValuePair "eth${toString second}"
52+ { ipAddress = "192.168.${toString first}.${toString m.second}";
53+ subnetMask = "255.255.255.0";
54+ });
055 in
56 { key = "ip-address";
57 config =
···60 networking.interfaces = listToAttrs interfaces;
6162 networking.primaryIPAddress =
63+ optionalString (interfaces != []) (head interfaces).value.ipAddress;
6465 # Put the IP addresses of all VMs in this machine's
66 # /etc/hosts file. If a machine has multiple