Install NixOS on Hetzner Cloud: Difference between revisions
imported>Raboof add traditional ISO variant, dream about disko/declarative |
imported>Mweinelt →Network configuration: Recommend a networkd based configuration |
||
| Line 39: | Line 39: | ||
== Network configuration == | == Network configuration == | ||
Hetzner Cloud offers both IPv4 (/32 subnet) and IPv6 (/64 subnet) connectivity to each machine. The assigned addresses can be looked up on the [https://console.hetzner.cloud Hetzner Cloud Console] from the "Networking" tab on the instance details. The public IPv4 address of the server can automatically obtained be via DHCP. For IPv6 you have to statically configure both address and gateway. | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | |||
systemd.network.enable = true; | |||
systemd.network.networks."10-wan" = { | |||
matchConfig.Name = "ens3"; # either ens3 (amd64) or enp1s0 (arm64) | |||
networkConfig.DHCP = "ipv4"; | |||
address = [ | |||
# replace this address with the one assigned to your instance | |||
"2a01:4f8:aaaa:bbbb::1/64" | |||
]; | |||
routes = [ | |||
{ routeConfig.Gateway = "fe80::1"; } | |||
]; | |||
}; | |||
</nowiki>}} | |||
=== Static IPv4 configuration === | |||
The IPv4 address can also be configured statically. The trick here is, that the gateway needs to be configured with the <code>onlink</code> flag, because it is not in the same subnet as your public IP address, but still very much on that same link. | |||
</ | |||
<syntaxhighlight lang="nix"> | |||
systemd.network.networks."10-wan" = { | |||
networkConfig.DHCP = "no"; | |||
address = [ | |||
# replace this address with the one assigned to your instance | |||
"A.B.C.D/32" | |||
]; | |||
routes = [ | |||
{ routeConfig = { Destination = "172.31.1.1"; }; } | |||
{ routeConfig = { Gateway = "172.31.1.1"; GatewayOnLink = true; }; } | |||
]; | |||
} | |||
</syntaxhighlight> | |||