Install NixOS on Hetzner Online: Difference between revisions

From NixOS Wiki
imported>Mic92
cleanup example
imported>Mic92
disable predictable interfaces
Line 9: Line 9:
== Network configuration ==
== Network configuration ==


From Hetzner's [ https://accounts.hetzner.com/login web interface], one can obtain both ipv4/ipv6 addresses and gateways.
From Hetzner's [https://accounts.hetzner.com/login web interface], one can obtain both ipv4/ipv6 addresses and gateways.
Hetzner does not operate dhcp servers, so you need to assign those statically.
Hetzner does not operate dhcp servers, so you need to assign those statically.
In this example we use networkd to configure the interface. The same configuration can be used for both
In this example we use networkd to configure the interface. The same configuration can be used for both
Line 17: Line 17:
{ ... }: {
{ ... }: {
   networking.dhcpcd.enable = false;
   networking.dhcpcd.enable = false;
  # this make sure that our interface is named `eth0`,
  # this should be ok as long as you don't have multiple physical network cards
  networking.usePredictableInterfaceNames = false;
   systemd.network.enable = true;
   systemd.network.enable = true;
   systemd.network = {
   systemd.network = {
      enable = true;
    enable = true;
      networks."eth0".extraConfig = ''
    networks."eth0".extraConfig = ''
        [Match]
      [Match]
        Name = eth0
      Name = eth0
        [Network]
      [Network]
        # Add your own assigned Ips/gateways here!
      # Add your own assigned Ips/gateways here!
        Address = 95.216.111.111/26
      Address = 95.216.111.111/26
        Gateway = 95.216.111.1
      Gateway = 95.216.111.1
        Address = 2a01:4f9:ffff::1/64
      Address = 2a01:4f9:ffff::1/64
        # this should be always fe80::1
      # this should be always fe80::1
        Gateway = fe80::1
      Gateway = fe80::1
      '';
    '';
   };
   };
}
}
</syntaxHighlight>
</syntaxHighlight>

Revision as of 12:48, 14 January 2019

This article is about installing NixOS on Hetzner Online, which provides dedicated bare-metal servers. This is not to be confused by Hetzner cloud, that provides VMs. There are three ways at the time to install NixOS on Hetzner

  1. From Hetzner's rescue image one can boot into the nixos installer using a custom kexec image that is configured with the fixed IP provied by Hetzner and also contain your ssh key. Tip: The kexec tarball as generated by nixos-generators can remain put into the /boot partition for future use.
  2. Hetzner also provides an interface to upload your own ISO-images. Also here you may want to build your own iso-image, which has openssh with ssh keys due the lack of a remote console.
  3. An easier method to install NixOS on Hetzner, is to use the existing integration into NixOps.

Network configuration

From Hetzner's web interface, one can obtain both ipv4/ipv6 addresses and gateways. Hetzner does not operate dhcp servers, so you need to assign those statically. In this example we use networkd to configure the interface. The same configuration can be used for both the kexec image and the final server.

{ ... }: {
  networking.dhcpcd.enable = false;
  # this make sure that our interface is named `eth0`, 
  # this should be ok as long as you don't have multiple physical network cards
  networking.usePredictableInterfaceNames = false;
  systemd.network.enable = true;
  systemd.network = {
    enable = true;
    networks."eth0".extraConfig = ''
      [Match]
      Name = eth0
      [Network]
      # Add your own assigned Ips/gateways here!
      Address = 95.216.111.111/26
      Gateway = 95.216.111.1
      Address = 2a01:4f9:ffff::1/64
      # this should be always fe80::1
      Gateway = fe80::1
    '';
  };
}