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

(^ 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 brd scope global prefix noprefixroute ens3
     # [...snip...]

# ip routes
default dev ens3 scope link src 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 broadcast dev ens3
# ip route add default via 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\nnameserver\nnameserver" >> /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 = ""; prefixLength = 24; }
  networking.defaultGateway = "";
  networking.nameservers = [
  # [...snip...]