Refactor nixos files relying on the old ipAddress / prefixLength / subnetMask attributes
This commit is contained in:
parent
1ff4b83875
commit
86c0f8c549
@ -12,12 +12,9 @@ interfaces. However, you can configure an interface manually as
|
|||||||
follows:
|
follows:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; };
|
networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
(The network prefix can also be specified using the option
|
|
||||||
<literal>subnetMask</literal>,
|
|
||||||
e.g. <literal>"255.255.255.0"</literal>, but this is deprecated.)
|
|
||||||
Typically you’ll also want to set a default gateway and set of name
|
Typically you’ll also want to set a default gateway and set of name
|
||||||
servers:
|
servers:
|
||||||
|
|
||||||
|
@ -48,10 +48,11 @@ rec {
|
|||||||
let
|
let
|
||||||
interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
|
interfacesNumbered = zipTwoLists config.virtualisation.vlans (range 1 255);
|
||||||
interfaces = flip map interfacesNumbered ({ first, second }:
|
interfaces = flip map interfacesNumbered ({ first, second }:
|
||||||
nameValuePair "eth${toString second}"
|
nameValuePair "eth${toString second}" { ip4 =
|
||||||
{ ipAddress = "192.168.${toString first}.${toString m.second}";
|
[ { address = "192.168.${toString first}.${toString m.second}";
|
||||||
subnetMask = "255.255.255.0";
|
prefixLength = 24;
|
||||||
});
|
} ];
|
||||||
|
}
|
||||||
in
|
in
|
||||||
{ key = "ip-address";
|
{ key = "ip-address";
|
||||||
config =
|
config =
|
||||||
@ -60,7 +61,7 @@ rec {
|
|||||||
networking.interfaces = listToAttrs interfaces;
|
networking.interfaces = listToAttrs interfaces;
|
||||||
|
|
||||||
networking.primaryIPAddress =
|
networking.primaryIPAddress =
|
||||||
optionalString (interfaces != []) (head interfaces).value.ipAddress;
|
optionalString (interfaces != []) (head (head interfaces).value.ip4).address;
|
||||||
|
|
||||||
# Put the IP addresses of all VMs in this machine's
|
# Put the IP addresses of all VMs in this machine's
|
||||||
# /etc/hosts file. If a machine has multiple
|
# /etc/hosts file. If a machine has multiple
|
||||||
|
@ -44,5 +44,5 @@ let virtualbox = config.boot.kernelPackages.virtualbox; in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.interfaces.vboxnet0 = { ipAddress = "192.168.56.1"; prefixLength = 24; };
|
networking.interfaces.vboxnet0.ip4 = [ { address = "192.168.56.1"; prefixLength = 24; } ];
|
||||||
}
|
}
|
||||||
|
@ -254,10 +254,10 @@ in
|
|||||||
networking.interfaces = mkOption {
|
networking.interfaces = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example =
|
example =
|
||||||
{ eth0 = {
|
{ eth0.ip4 = [ {
|
||||||
ipAddress = "131.211.84.78";
|
address = "131.211.84.78";
|
||||||
subnetMask = "255.255.255.128";
|
prefixLength = 25;
|
||||||
};
|
} ];
|
||||||
};
|
};
|
||||||
description = ''
|
description = ''
|
||||||
The configuration for each network interface. If
|
The configuration for each network interface. If
|
||||||
|
@ -16,7 +16,7 @@ let
|
|||||||
miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf"
|
miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf"
|
||||||
''
|
''
|
||||||
ext_ifname=eth1
|
ext_ifname=eth1
|
||||||
listening_ip=${nodes.router.config.networking.interfaces.eth2.ipAddress}/24
|
listening_ip=${(head nodes.router.config.networking.interfaces.eth2.ip4).address}/24
|
||||||
allow 1024-65535 192.168.2.0/24 1024-65535
|
allow 1024-65535 192.168.2.0/24 1024-65535
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ in
|
|||||||
{ environment.systemPackages = [ pkgs.transmission ];
|
{ environment.systemPackages = [ pkgs.transmission ];
|
||||||
virtualisation.vlans = [ 2 ];
|
virtualisation.vlans = [ 2 ];
|
||||||
networking.defaultGateway =
|
networking.defaultGateway =
|
||||||
nodes.router.config.networking.interfaces.eth2.ipAddress;
|
(head nodes.router.config.networking.interfaces.eth2.ip4).address;
|
||||||
networking.firewall.enable = false;
|
networking.firewall.enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ in
|
|||||||
# Create the torrent.
|
# Create the torrent.
|
||||||
$tracker->succeed("mkdir /tmp/data");
|
$tracker->succeed("mkdir /tmp/data");
|
||||||
$tracker->succeed("cp ${file} /tmp/data/test.tar.bz2");
|
$tracker->succeed("cp ${file} /tmp/data/test.tar.bz2");
|
||||||
$tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -t http://${nodes.tracker.config.networking.interfaces.eth1.ipAddress}:6969/announce -o /tmp/test.torrent");
|
$tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -t http://${(head nodes.tracker.config.networking.interfaces.eth1.ip4).address}:6969/announce -o /tmp/test.torrent");
|
||||||
$tracker->succeed("chmod 644 /tmp/test.torrent");
|
$tracker->succeed("chmod 644 /tmp/test.torrent");
|
||||||
|
|
||||||
# Start the tracker. !!! use a less crappy tracker
|
# Start the tracker. !!! use a less crappy tracker
|
||||||
|
@ -13,7 +13,7 @@ import ./make-test.nix {
|
|||||||
{ virtualisation.vlans = [ 1 ];
|
{ virtualisation.vlans = [ 1 ];
|
||||||
networking.firewall.allowPing = true;
|
networking.firewall.allowPing = true;
|
||||||
networking.defaultGateway =
|
networking.defaultGateway =
|
||||||
nodes.router.config.networking.interfaces.eth2.ipAddress;
|
(head nodes.router.config.networking.interfaces.eth2.ip4).address;
|
||||||
};
|
};
|
||||||
|
|
||||||
router =
|
router =
|
||||||
|
Loading…
Reference in New Issue
Block a user