-
-
Notifications
You must be signed in to change notification settings - Fork 363
hetzner: Set prefix length to /32 for main address #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This was already suggested by @flokli in NixOS#1032 and it basically makes sure that all traffic is sent to the gateway instead of being sent directly. The Hetzner Wiki at [1] describes configuration of Debian to include a "peertopeer" directive in /etc/network/interfaces, which roughly translates to the command "ip address add ... peer A.B.C.D". However, after testing with and without the peer keyword of "ip address" I didn't notice any difference in behaviour in comparison to setting a plain /32 prefix length as we do now. Apart from making configuration less complicated, this also gets rid of a bunch of code we now no longer need, eg. calculating subnet masks or getting the real prefix length. Tested on a newly deployed PX61-NVMe. [1]: https://wiki.hetzner.de/index.php/Netzkonfiguration_Debian/en#Dedicated_Servers Signed-off-by: aszlig <aszlig@nix.build>
@aszlig how does the routing table now look like on a newly provisioned server? |
@flokli: With # ip r
default via 1.2.3.4 dev eth0 proto static
1.2.3.4 dev eth0 proto static scope link
# ip a s eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
inet 1.2.3.5/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 1234::/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::4321/64 scope link
valid_lft forever preferred_lft forever |
So how is the Is that some magic somewhere deep in the NixOS networking scripts? I'm asking because I use networkd, and had to configure a peer there too:
|
Nope, the address is simply added via
Hm, I guess import <nixpkgs/nixos/tests/make-test.nix> {
name = "test-prefix32-networkd";
nodes = let
common = {
networking.useDHCP = false;
networking.firewall.enable = false;
};
in {
node1 = { lib, ... }: {
imports = [ common ];
virtualisation.vlans = [ 1 ];
networking.useNetworkd = true;
networking.defaultGateway = {
address = "1.2.0.1";
interface = "eth1";
};
networking.interfaces = lib.mkOverride 0 {
eth1.ipv4.addresses = lib.singleton {
address = "1.2.3.4";
prefixLength = 32;
};
};
};
node2 = { lib, ... }: {
imports = [ common ];
virtualisation.vlans = [ 2 ];
networking.useNetworkd = true;
networking.defaultGateway = {
address = "1.2.0.2";
interface = "eth1";
};
networking.interfaces = lib.mkOverride 0 {
eth1.ipv4.addresses = lib.singleton {
address = "1.2.3.5";
prefixLength = 32;
};
};
};
router = { lib, ... }: {
imports = [ common ];
virtualisation.vlans = [ 1 2 ];
boot.kernel.sysctl."net.ipv4.ip_forward" = true;
networking.interfaces = lib.mkOverride 0 {
eth1.ipv4.addresses = lib.singleton {
address = "1.2.0.1";
prefixLength = 16;
};
eth2.ipv4.addresses = lib.singleton {
address = "1.2.0.2";
prefixLength = 16;
};
};
networking.localCommands = ''
ip route add 1.2.0.0/16 dev eth1 src 1.2.0.1 table 10
ip route add 1.2.0.0/16 dev eth2 src 1.2.0.2 table 20
ip rule add table 20 to 1.2.3.5
ip rule add table 10 to 1.2.3.4
'';
};
};
testScript = ''
startAll;
$router->waitForUnit('multi-user.target');
$node1->waitForUnit('multi-user.target');
$node2->waitForUnit('multi-user.target');
$node1->succeed('ping -c1 1.2.3.5');
$node2->succeed('ping -c1 1.2.3.4');
'';
} Output:
Setting |
My question was more about the route to For comparison, I use that configuration for networkd:
I'm not sure if we want to fix this for current setups first, and tackle "automatic" networkd support at a later point of time - there's some refactorization of the networkd support planned for NixOS anyway - cc @fpletz |
Hello! Thank you for this PR. In the past several months, some major changes have taken place in
This is all accumulating in to what I hope will be a NixOps 2.0 My hope is that by adding types and more thorough automated testing, However, because of the major changes, it has become likely that this If you would like to see this merge, please bring it up to date with Thank you again for the work you've done here, I am sorry to be Graham |
I think this PR should be revived (it was not revived into `nixops-hetzner), see here: #1032 (comment) |
This was already suggested by @flokli in #1032 and it basically makes sure that all traffic is sent to the gateway instead of being sent directly.
The Hetzner Wiki describes configuration of Debian to include a
peertopeer
directive in/etc/network/interfaces
, which roughly translates to the commandip address add ... peer A.B.C.D
.However, after testing with and without the
peer
keyword ofip address
I didn't notice any difference in behavior in comparison to setting a plain /32 prefix length as we do now.Apart from making configuration less complicated, this also gets rid of a bunch of code we now no longer need, eg. calculating subnet masks or getting the real prefix length.
Tested on a newly deployed PX61-NVMe.
@nh2, @flokli, @basvandijk: If possible, can you test this and check whether this causes any problems?