Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hetzner: Don't use localCommands, set interface device of default gat…
…eway. Should help #833. Original localCommands patch by aszlig. Fixups and interface device stuff from me. Note that this new way of doing it without localCommands is backwards incompatible with NixOS < 18.03, see: https://nixos.org/nixos/manual/release-notes.html#sec-release-18.03-notable-changes As described on https://wiki.hetzner.de/index.php/Netzkonfiguration_Debian/en#IPv4 Hetzner requires that even traffic to the local subnet goes via the gateway. NixOps already had code for that (set in `localCommands`), but it wasn't enough: The ip route replace default via "GATEWAY_IP" proto static generated by `network-setup.service` in NixOS's `network-interface-scripted.nix` fails with RTNETLINK answers: Network is unreachable because all routes added so far had `via "GATEWAY_IP"`, but the kernel didn't know how to actually reach GATEWAY_IP because there was no static route for that IP, see. https://serverfault.com/questions/581159/unable-to-add-a-static-route-sioaddrt-network-is-unreachable/581162#581162 This commit adds an explicit static route to the default gateway, on the relevant network device. This allows us to generate the following instead: ip route replace GATEWAY_IP dev THE_DEVICE proto static ip route replace default via "GATEWAY_IP" dev THE_DEVICE proto static so that the kernel knows how to reach the gateway. An example of what routes look like in `ip route` after deploying and 18.03 machine, where 1.2.3.4 is the server's IP and 1.2.3.1 is the gateway: default via 1.2.3.1 dev eth0 src 1.2.3.4 metric 202 1.2.3.0/27 dev eth0 proto kernel scope link src 1.2.3.4 metric 202 1.2.3.1 dev eth0 proto static scope link For IPv6, the link-local `fe80::1` is the gateway, as described on https://wiki.hetzner.de/index.php/Netzkonfiguration_Debian/en#IPv6 Signed-off-by: Niklas Hambüchen <mail@nh2.me>
- Loading branch information