Install NixOS on Hetzner Online: Difference between revisions
imported>Nilsherzig No edit summary |
m Category:Deployment added |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 12: | Line 12: | ||
== Network configuration == | == Network configuration == | ||
Hetzner Online offers both IPv4 (usually in a shared /26 or /27 subnet) and IPv6 (/64 subnet) connectivity to each machine. The assigned addresses can be looked up on the [https://robot.hetzner.com/server Hetzner Robot] on the IPs tab of a machine. The public IPv4 address of the server can automatically be obtained via DHCP. For IPv6 you have to statically configure both address and gateway. | |||
< | <syntaxhighlight lang="nix"> | ||
{ | { | ||
systemd.network = { | systemd.network = { | ||
enable = true; | enable = true; | ||
networks. | networks.default = { | ||
name = "enp1s0"; # The name of the interface | |||
DHCP = "ipv4"; | |||
[ | addresses = [ | ||
{ | |||
# Replace the address with the one assigned to your machine | |||
Address = "2a01:4f8:AAAA:BBBB::1/64"; | |||
} | |||
]; | |||
gateway = [ "fe80::1" ]; | |||
linkConfig.RequiredForOnline = "routable"; | |||
}; | |||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
=== Static IPv4 configuration === | |||
< | Since the IPv4 network configuration is known, it can also be configured statically, preventing reliance on the DHCP service. The gateway and subnet information is visible when hovering the IPv4 address. The subnet size is usually a /26 (<code>255.255.255.224</code>) or a /27 (<code>255.255.255.192</code>).<syntaxhighlight lang="nix"> | ||
{ | |||
systemd.network = { | |||
enable = true; | |||
networks."30-wan" = { | |||
name = "enp1s0"; # The predictable name of the network interface | |||
DHCP = "no"; | |||
addresses = [ | |||
# Replace the addresses with the ones assigned to your machine | |||
{ | |||
Address = "A.B.C.D/26"; | |||
} | |||
{ | |||
Address = "2a01:4f8:AAAA:BBBB::1/64"; | |||
} | |||
]; | |||
gateway = [ | |||
# Replace the gateway address with the one in your subnet | |||
"A.B.C.E" | |||
"fe80::1" | |||
address | ]; | ||
linkConfig.RequiredForOnline = "routable"; | |||
}; | }; | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
== Bootstrap from the Rescue System == | == Bootstrap from the Rescue System == | ||
| Line 157: | Line 145: | ||
At this point, edit the /mnt/etc/nixos/configuration.nix and tune as needed. I just added the following lines: | At this point, edit the /mnt/etc/nixos/configuration.nix and tune as needed. I just added the following lines: | ||
<syntaxHighlight> | <syntaxHighlight lang=nix> | ||
boot.loader.grub.device = "/dev/nvme0n1"; | boot.loader.grub.device = "/dev/nvme0n1"; | ||
services.openssh.enable = true; | services.openssh.enable = true; | ||
| Line 169: | Line 157: | ||
Voila! (after 1000 steps) | Voila! (after 1000 steps) | ||
[[Category:Cookbook]] | |||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Deployment]] | |||