Broken network while installing NixOS via the minimal ISO image on a VPS

Hello. I’m want to install NixOS on a VPS hosting that doesn’t offer NixOS installations out of the box, but they support booting from an ISO image. When I mounted and booted the VPS into the installation ISO, I noticed two networking issues:

  • I couldn’t resolve any hostname;
  • I couldn’t succesfully ping any public IP either.

I looked up the IP addresses assigned to my VPS by the hoster in the admin panel:

IP Address Network Mask Gateway
95.132.101.114 255.255.255.0 95.132.101.1

(^ these are fake addresses)

While running ip address show ens3 and ip routes showed a different address and a gateway were set up for the interface:

# ip address show ens3
     # [...snip...]
     # notice /16 prefix doesn't match the correct network mask
     inet 168.253.182.161/16 brd 168.253.255.255 scope global prefix noprefixroute ens3
     # [...snip...]

# ip routes
default dev ens3 scope link src 168.253.182.161 metric 1001002
# [...snip...]

(^ these are fake addresses)

Also, /etc/resolv.conf had no nameserver entries.

I believe dhcpcd is responsible for setting up the network in the installer, so I disabled it and added the IP address and the default gateway route by hand:

# systemctl stop dhcpcd
# ip address add 95.132.101.114/24 broadcast 95.132.101.255 dev ens3
# ip route add default via 95.132.101.1 dev ens3 proto static metric 100

At this point ping-ing public IPs works, but hostname resolution doesn’t. Adding CloudFlare and Google resolvers to /etc/resolv.conf fixed that:

# echo -e "nameserver 1.1.1.1\nnameserver 8.8.8.8\nnameserver 8.8.4.4" >> /etc/resolv.conf

Then I could proceed with the installation.


The question is why the installer had non-functional networking setup? Is this an installer issue that can be fixed? Or is the hosting company’s infrastructure to blame?

Bonus question: I’m a noob when it comes to networking and while I managed to set it up in the end, is the setup correct/optimal? Is there any way I could handle this issue better? I haven’t found any mentions of related issues in the manual (though it’s probably out of the scope of the manual).

Thanks in advance!

I have just successfully installed NixOS on the VPS, and the same issue with DHCP networking setup exists on the installed system, which I solved by static network configuration as per Networking docs:

{ config, pkgs, ... }:

{
  # [...snip...]
  networking.interfaces.ens3 = {
    useDHCP = false;
    ipv4.addresses = [
      { address = "95.132.100.114"; prefixLength = 24; }
    ];
  };
  networking.defaultGateway = "95.132.100.1";
  networking.nameservers = [
    "1.1.1.1"
    "8.8.8.8"
    "8.8.4.4"
  ];
  # [...snip...]
}