Install NixOS on Hetzner Online: Difference between revisions
imported>IgorM m Fixed syntax highlighting |
→Network configuration: Bring in sync with Hetzner cloud and give only networkd examples for a static config, as well as one using DHCP |
||
Line 12: | Line 12: | ||
== Network configuration == | == Network configuration == | ||
Hetzner Cloud offers both IPv4 (/32 or shorter subnets) 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."30-wan" = { | ||
matchConfig.Name = "enp1s0"; # The predictable name of the network interface | |||
networkConfig.DHCP = "ipv4"; | |||
[ | addresses = [ | ||
# Replace the subnet with the one assigned to your machine | |||
"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 (255.255.255.224) or a /27 (255.255.255.192).<syntaxhighlight lang="nix"> | ||
{ | |||
systemd.network = { | |||
enable = true; | |||
networks."30-wan" = { | |||
matchConfig.Name = "enp1s0"; # The predictable name of the network interface | |||
networkConfig.DHCP = "no"; | |||
addresses = [ | |||
# Replace the address and subnet with the one assigned to your machine | |||
"A.B.C.D/26" | |||
# Replace the subnet with the one assigned to your machine | |||
"2a01:4f8:AAAA:BBBB::1/64" | |||
]; | |||
gateway = [ | |||
# Replace the gateway address with the one in your subnet | |||
"A.B.C.E" | |||
address | "fe80::1" | ||
]; | |||
linkConfig.RequiredForOnline = "routable"; | |||
address | |||
}; | }; | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
== Bootstrap from the Rescue System == | == Bootstrap from the Rescue System == |