Revert "Merge pull request #3182 from wkennington/master.ipv6"

This reverts commit b23fd6585481a42937e105d5fce630a549900e86, reversing
changes made to 43654cba2c280ce17b81db44993d1c1bcae3a9c6.

+57 -118
+4 -1
nixos/doc/manual/configuration/ipv4-config.xml
··· 12 follows: 13 14 <programlisting> 15 - networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ]; 16 </programlisting> 17 18 Typically you’ll also want to set a default gateway and set of name 19 servers: 20
··· 12 follows: 13 14 <programlisting> 15 + networking.interfaces.eth0 = { ipAddress = "192.168.1.2"; prefixLength = 24; }; 16 </programlisting> 17 18 + (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.) 21 Typically you’ll also want to set a default gateway and set of name 22 servers: 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; 62 63 networking.primaryIPAddress = 64 - optionalString (interfaces != []) (head (head interfaces).value.ip4).address; 65 66 # 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 + }); 55 in 56 { key = "ip-address"; 57 config = ··· 60 networking.interfaces = listToAttrs interfaces; 61 62 networking.primaryIPAddress = 63 + optionalString (interfaces != []) (head interfaces).value.ipAddress; 64 65 # Put the IP addresses of all VMs in this machine's 66 # /etc/hosts file. If a machine has multiple
+1 -1
nixos/modules/programs/virtualbox.nix
··· 44 ''; 45 }; 46 47 - networking.interfaces.vboxnet0.ip4 = [ { address = "192.168.56.1"; prefixLength = 24; } ]; 48 }
··· 44 ''; 45 }; 46 47 + networking.interfaces.vboxnet0 = { ipAddress = "192.168.56.1"; prefixLength = 24; }; 48 }
+1 -1
nixos/modules/services/networking/dhcpcd.nix
··· 11 # Don't start dhcpcd on explicitly configured interfaces or on 12 # interfaces that are part of a bridge, bond or sit device. 13 ignoredInterfaces = 14 - map (i: i.name) (filter (i: i.ip4 != [ ] || i.ipAddress != null) (attrValues config.networking.interfaces)) 15 ++ mapAttrsToList (i: _: i) config.networking.sits 16 ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bridges)) 17 ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds))
··· 11 # Don't start dhcpcd on explicitly configured interfaces or on 12 # interfaces that are part of a bridge, bond or sit device. 13 ignoredInterfaces = 14 + map (i: i.name) (filter (i: i.ipAddress != null) (attrValues config.networking.interfaces)) 15 ++ mapAttrsToList (i: _: i) config.networking.sits 16 ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bridges)) 17 ++ concatLists (attrValues (mapAttrs (n: v: v.interfaces) config.networking.bonds))
+42 -105
nixos/modules/tasks/network-interfaces.nix
··· 10 hasSits = cfg.sits != { }; 11 hasBonds = cfg.bonds != { }; 12 13 - addrOpts = v: 14 - assert v == 4 || v == 6; 15 - { 16 - address = mkOption { 17 - type = types.str; 18 - description = '' 19 - IPv${toString v} address of the interface. Leave empty to configure the 20 - interface using DHCP. 21 - ''; 22 - }; 23 - 24 - prefixLength = mkOption { 25 - type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128)); 26 - description = '' 27 - Subnet mask of the interface, specified as the number of 28 - bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>). 29 - ''; 30 - }; 31 - }; 32 - 33 interfaceOpts = { name, ... }: { 34 35 options = { ··· 40 description = "Name of the interface."; 41 }; 42 43 - ip4 = mkOption { 44 - default = [ ]; 45 - example = [ 46 - { address = "10.0.0.1"; prefixLength = 16; } 47 - { address = "192.168.1.1"; prefixLength = 24; } 48 - ]; 49 - type = types.listOf types.optionSet; 50 - options = addrOpts 4; 51 - description = '' 52 - List of IPv4 addresses that will be statically assigned to the interface. 53 - ''; 54 - }; 55 - 56 - ip6 = mkOption { 57 - default = [ ]; 58 - example = [ 59 - { address = "fdfd:b3f0:482::1"; prefixLength = 48; } 60 - { address = "2001:1470:fffd:2098::e006"; prefixLength = 64; } 61 - ]; 62 - type = types.listOf types.optionSet; 63 - options = addrOpts 6; 64 - description = '' 65 - List of IPv6 addresses that will be statically assigned to the interface. 66 - ''; 67 - }; 68 - 69 ipAddress = mkOption { 70 default = null; 71 example = "10.0.0.1"; 72 - type = types.nullOr types.str; 73 description = '' 74 IP address of the interface. Leave empty to configure the 75 interface using DHCP. ··· 87 }; 88 89 subnetMask = mkOption { 90 - default = null; 91 description = '' 92 - Defunct, supply the prefix length instead. 93 ''; 94 }; 95 96 ipv6Address = mkOption { 97 default = null; 98 example = "2001:1470:fffd:2098::e006"; 99 - type = types.nullOr types.str; 100 description = '' 101 IPv6 address of the interface. Leave empty to configure the 102 interface using NDP. ··· 266 networking.interfaces = mkOption { 267 default = {}; 268 example = 269 - { eth0.ip4 = [ { 270 - address = "131.211.84.78"; 271 - prefixLength = 25; 272 - } ]; 273 }; 274 description = '' 275 The configuration for each network interface. If ··· 480 481 config = { 482 483 - assertions = 484 - flip map interfaces (i: { 485 - assertion = i.subnetMask == null; 486 - message = "The networking.interfaces.${i.name}.subnetMask option is defunct. Use prefixLength instead."; 487 - }); 488 - 489 boot.kernelModules = [ ] 490 ++ optional cfg.enableIPv6 "ipv6" 491 ++ optional hasVirtuals "tun" ··· 582 # network device, so it only gets started after the interface 583 # has appeared, and it's stopped when the interface 584 # disappears. 585 - configureInterface = i: 586 - let 587 - ips = i.ip4 ++ optionals cfg.enableIPv6 i.ip6 588 - ++ optional (i.ipAddress != null) { 589 - ipAddress = i.ipAddress; 590 - prefixLength = i.prefixLength; 591 - } ++ optional (cfg.enableIPv6 && i.ipv6Address != null) { 592 - ipAddress = i.ipv6Address; 593 - prefixLength = i.ipv6PrefixLength; 594 - }; 595 in 596 - nameValuePair "${i.name}-cfg" 597 { description = "Configuration of ${i.name}"; 598 wantedBy = [ "network-interfaces.target" ]; 599 bindsTo = [ "sys-subsystem-net-devices-${i.name}.device" ]; ··· 616 echo "setting MTU to ${toString i.mtu}..." 617 ip link set "${i.name}" mtu "${toString i.mtu}" 618 '' 619 - 620 - # Ip Setup 621 - + 622 '' 623 - curIps=$(ip -o a show dev "${i.name}" | awk '{print $4}') 624 - # Only do an add if it's necessary. This is 625 # useful when the Nix store is accessed via this 626 # interface (e.g. in a QEMU VM test). 627 '' 628 - + flip concatMapStrings (ips) (ip: 629 - let 630 - address = "${ip.address}/${toString ip.prefixLength}"; 631 - in 632 '' 633 - echo "checking ip ${address}..." 634 - if ! echo "$curIps" | grep "${address}" >/dev/null 2>&1; then 635 - if out=$(ip addr add "${address}" dev "${i.name}" 2>&1); then 636 - echo "added ip ${address}..." 637 - restart_network_setup=true 638 - elif ! echo "$out" | grep "File exists" >/dev/null 2>&1; then 639 - echo "failed to add ${address}" 640 - exit 1 641 - fi 642 fi 643 - '') 644 - + optionalString (ips != [ ]) 645 '' 646 if [ restart_network_setup = true ]; then 647 # Ensure that the default gateway remains set. ··· 658 '' 659 echo 1 > /proc/sys/net/ipv6/conf/${i.name}/proxy_ndp 660 ''; 661 - preStop = 662 - '' 663 - echo "releasing configured ip's..." 664 - '' 665 - + flip concatMapStrings (ips) (ip: 666 - let 667 - address = "${ip.address}/${toString ip.prefixLength}"; 668 - in 669 - '' 670 - echo -n "Deleting ${address}..." 671 - ip addr del "${address}" dev "${i.name}" >/dev/null 2>&1 || echo -n " Failed" 672 - echo "" 673 - ''); 674 - }; 675 676 createTunDevice = i: nameValuePair "${i.name}" 677 { description = "Virtual Network Interface ${i.name}";
··· 10 hasSits = cfg.sits != { }; 11 hasBonds = cfg.bonds != { }; 12 13 interfaceOpts = { name, ... }: { 14 15 options = { ··· 20 description = "Name of the interface."; 21 }; 22 23 ipAddress = mkOption { 24 default = null; 25 example = "10.0.0.1"; 26 + type = types.nullOr (types.str); 27 description = '' 28 IP address of the interface. Leave empty to configure the 29 interface using DHCP. ··· 41 }; 42 43 subnetMask = mkOption { 44 + default = ""; 45 + example = "255.255.255.0"; 46 + type = types.str; 47 description = '' 48 + Subnet mask of the interface, specified as a bitmask. 49 + This is deprecated; use <option>prefixLength</option> 50 + instead. 51 ''; 52 }; 53 54 ipv6Address = mkOption { 55 default = null; 56 example = "2001:1470:fffd:2098::e006"; 57 + type = types.nullOr types.string; 58 description = '' 59 IPv6 address of the interface. Leave empty to configure the 60 interface using NDP. ··· 224 networking.interfaces = mkOption { 225 default = {}; 226 example = 227 + { eth0 = { 228 + ipAddress = "131.211.84.78"; 229 + subnetMask = "255.255.255.128"; 230 + }; 231 }; 232 description = '' 233 The configuration for each network interface. If ··· 438 439 config = { 440 441 boot.kernelModules = [ ] 442 ++ optional cfg.enableIPv6 "ipv6" 443 ++ optional hasVirtuals "tun" ··· 534 # network device, so it only gets started after the interface 535 # has appeared, and it's stopped when the interface 536 # disappears. 537 + configureInterface = i: nameValuePair "${i.name}-cfg" 538 + (let mask = 539 + if i.prefixLength != null then toString i.prefixLength else 540 + if i.subnetMask != "" then i.subnetMask else "32"; 541 + staticIPv6 = cfg.enableIPv6 && i.ipv6Address != null; 542 in 543 { description = "Configuration of ${i.name}"; 544 wantedBy = [ "network-interfaces.target" ]; 545 bindsTo = [ "sys-subsystem-net-devices-${i.name}.device" ]; ··· 562 echo "setting MTU to ${toString i.mtu}..." 563 ip link set "${i.name}" mtu "${toString i.mtu}" 564 '' 565 + + optionalString (i.ipAddress != null) 566 '' 567 + cur=$(ip -4 -o a show dev "${i.name}" | awk '{print $4}') 568 + # Only do a flush/add if it's necessary. This is 569 # useful when the Nix store is accessed via this 570 # interface (e.g. in a QEMU VM test). 571 + if [ "$cur" != "${i.ipAddress}/${mask}" ]; then 572 + echo "configuring interface..." 573 + ip -4 addr flush dev "${i.name}" 574 + ip -4 addr add "${i.ipAddress}/${mask}" dev "${i.name}" 575 + restart_network_setup=true 576 + else 577 + echo "skipping configuring interface" 578 + fi 579 '' 580 + + optionalString (staticIPv6) 581 '' 582 + # Only do a flush/add if it's necessary. This is 583 + # useful when the Nix store is accessed via this 584 + # interface (e.g. in a QEMU VM test). 585 + if ! ip -6 -o a show dev "${i.name}" | grep "${i.ipv6Address}/${toString i.ipv6prefixLength}"; then 586 + echo "configuring interface..." 587 + ip -6 addr flush dev "${i.name}" 588 + ip -6 addr add "${i.ipv6Address}/${toString i.ipv6prefixLength}" dev "${i.name}" 589 + restart_network_setup=true 590 + else 591 + echo "skipping configuring interface" 592 fi 593 + '' 594 + + optionalString (i.ipAddress != null || staticIPv6) 595 '' 596 if [ restart_network_setup = true ]; then 597 # Ensure that the default gateway remains set. ··· 608 '' 609 echo 1 > /proc/sys/net/ipv6/conf/${i.name}/proxy_ndp 610 ''; 611 + }); 612 613 createTunDevice = i: nameValuePair "${i.name}" 614 { description = "Virtual Network Interface ${i.name}";
+3 -3
nixos/tests/bittorrent.nix
··· 16 miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf" 17 '' 18 ext_ifname=eth1 19 - listening_ip=${(head nodes.router.config.networking.interfaces.eth2.ip4).address}/24 20 allow 1024-65535 192.168.2.0/24 1024-65535 21 ''; 22 ··· 53 { environment.systemPackages = [ pkgs.transmission ]; 54 virtualisation.vlans = [ 2 ]; 55 networking.defaultGateway = 56 - (head nodes.router.config.networking.interfaces.eth2.ip4).address; 57 networking.firewall.enable = false; 58 }; 59 ··· 81 # Create the torrent. 82 $tracker->succeed("mkdir /tmp/data"); 83 $tracker->succeed("cp ${file} /tmp/data/test.tar.bz2"); 84 - $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"); 85 $tracker->succeed("chmod 644 /tmp/test.torrent"); 86 87 # Start the tracker. !!! use a less crappy tracker
··· 16 miniupnpdConf = nodes: pkgs.writeText "miniupnpd.conf" 17 '' 18 ext_ifname=eth1 19 + listening_ip=${nodes.router.config.networking.interfaces.eth2.ipAddress}/24 20 allow 1024-65535 192.168.2.0/24 1024-65535 21 ''; 22 ··· 53 { environment.systemPackages = [ pkgs.transmission ]; 54 virtualisation.vlans = [ 2 ]; 55 networking.defaultGateway = 56 + nodes.router.config.networking.interfaces.eth2.ipAddress; 57 networking.firewall.enable = false; 58 }; 59 ··· 81 # Create the torrent. 82 $tracker->succeed("mkdir /tmp/data"); 83 $tracker->succeed("cp ${file} /tmp/data/test.tar.bz2"); 84 + $tracker->succeed("transmission-create /tmp/data/test.tar.bz2 -t http://${nodes.tracker.config.networking.interfaces.eth1.ipAddress}:6969/announce -o /tmp/test.torrent"); 85 $tracker->succeed("chmod 644 /tmp/test.torrent"); 86 87 # Start the tracker. !!! use a less crappy tracker
+1 -1
nixos/tests/nat.nix
··· 13 { virtualisation.vlans = [ 1 ]; 14 networking.firewall.allowPing = true; 15 networking.defaultGateway = 16 - (head nodes.router.config.networking.interfaces.eth2.ip4).address; 17 }; 18 19 router =
··· 13 { virtualisation.vlans = [ 1 ]; 14 networking.firewall.allowPing = true; 15 networking.defaultGateway = 16 + nodes.router.config.networking.interfaces.eth2.ipAddress; 17 }; 18 19 router =