elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)
GNU General Public License v3.0
1.37k stars 221 forks source link

Invalid networking.nix for IPv6-only machines #151

Open fleaz opened 1 year ago

fleaz commented 1 year ago

Hey,

just used this tool on a VM on Hetzner for which I didn't configured an IPv4 address. The generated networking.nix is invalid and can't be applied because there is an empty /32 IPv4 route.

Generated networking.nix:

{ lib, ... }: {
  # This file was populated at runtime with the networking
  # details gathered from the active system.
  networking = {
    nameservers = [ "8.8.8.8"
 ];
    defaultGateway = "";
    defaultGateway6 = {
      address = "fe80::1";
      interface = "eth0";
    };
    dhcpcd.enable = false;
    usePredictableInterfaceNames = lib.mkForce false;
    interfaces = {
      eth0 = {
        ipv4.addresses = [
          { address="100.64.194.249"; prefixLength=32; }
        ];
        ipv6.addresses = [
          { address="2a01:4f8:c0c:65c2::1"; prefixLength=64; }
{ address="fe80::9400:2ff:fe27:2e0b"; prefixLength=64; }
        ];
        ipv4.routes = [ { address = ""; prefixLength = 32; } ];
        ipv6.routes = [ { address = "fe80::1"; prefixLength = 128; } ];
      };

    };
  };
  services.udev.extraRules = ''
    ATTR{address}=="96:00:02:27:2e:0b", NAME="eth0"

  '';
}

This is what the interfaces look like on a fresh IPv6 only machine booted into their stock Ubuntu:

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 96:00:02:27:4a:20 brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    altname ens3
    inet 100.66.8.195/32 metric 100 scope global dynamic eth0
       valid_lft 86280sec preferred_lft 86280sec
    inet6 2a01:4f9:c012:859b::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::9400:2ff:fe27:4a20/64 scope link 
       valid_lft forever preferred_lft forever

# ip -4 r
169.254.169.254 via 172.31.1.1 dev eth0 proto dhcp src 100.66.8.195 metric 100 
172.31.1.1 dev eth0 proto dhcp scope link src 100.66.8.195 metric 100 

# ip -6 r
::1 dev lo proto kernel metric 256 pref medium
2a01:4f9:c012:859b::/64 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
default via fe80::1 dev eth0 proto static metric 1024 onlink pref medium

Happy to provide more information and help debug this if needed.

Best, Felix

jmmaloney4 commented 1 year ago

On vultr, I was able to get ipv6 to work immediately. It doesn't appear to have generated a networking.nix, or have any networking setup in the configuration.nix or hardware-configuration.nix. I did run into a separate problem, however, which is that GitHub does not support IPv6, rendering nixpkgs unusable.

Chobbes commented 7 months ago

Ran into the same issue. Additionally nixos-infect only uses the single ipv4 nameserver 8.8.8.8, so DNS doesn't work by default. Had to edit /etc/resolv.conf in order to get a rebuild to work.