Created
April 22, 2021 15:27
-
-
Save lheckemann/15cf1a6be26d442951cb0a09a0e50749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
let | |
inherit (pkgs) lib; | |
defaults = { | |
options.networking.interfaces = lib.mkOption { | |
type = lib.types.attrsOf (lib.types.submodule { | |
useDHCP = false; | |
}); | |
}; | |
}; | |
in pkgs.nixosTest { | |
name = "duplicated-routes"; | |
nodes = { | |
client = { lib, ... }: { | |
imports = [defaults]; | |
virtualisation.vlans = [1]; | |
networking = { | |
useDHCP = false; | |
interfaces.eth1 = lib.mkForce { | |
tempAddress = "disabled"; | |
ipv6.routes = [ | |
# Intentionally bogus default route. This should be | |
# replaced by the route obtained via NDP, or prevent the | |
# route obtained from NDP from being added to the routing | |
# table. Instead, we get two entries in the routing table | |
# with the same destination and the same metric. When | |
# actual routing is taking place, the choice of which one | |
# is used seems to be arbitrary, but somewhat favour the | |
# NDP route. | |
{ address = "::"; prefixLength = 0; via = "fe80::5235"; } | |
]; | |
}; | |
}; | |
}; | |
router = { lib, ... }: { | |
imports = [defaults]; | |
virtualisation.vlans = [1 2]; | |
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = true; | |
services.radvd = { | |
enable = true; | |
config = '' | |
interface eth1 { | |
AdvSendAdvert on; | |
prefix fd00::/64 { | |
AdvAutonomous on; | |
AdvOnLink on; | |
}; | |
}; | |
''; | |
}; | |
networking = { | |
useDHCP = false; | |
interfaces = lib.mkForce { | |
eth1.ipv6.addresses = [ | |
{ address = "fd00::"; prefixLength = 64; } | |
{ address = "fe80::1"; prefixLength = 64; } | |
]; | |
eth2.ipv6.addresses = [ | |
{ address = "2001:db8::"; prefixLength = 32; } | |
]; | |
}; | |
}; | |
}; | |
server = { lib, ... }: { | |
imports = [defaults]; | |
virtualisation.vlans = [2]; | |
networking.useDHCP = false; | |
networking.interfaces = lib.mkForce { | |
eth1.ipv6.addresses = [ | |
{ address = "2001:db8::2"; prefixLength = 32; } | |
]; | |
eth1.ipv6.routes = [ | |
{ address = "fd00::"; prefixLength = 64; via = "2001:db8::";} | |
]; | |
}; | |
}; | |
}; | |
skipLint = true; | |
testScript = '' | |
start_all() | |
router.wait_for_unit("radvd.service") | |
client.wait_until_succeeds("ip -o a show scope global | grep inet6") | |
print(client.succeed("ip a")) | |
print(client.succeed("ip -6 r")) | |
for addr in "fe80::1%eth1 fd00:: 2001:db8::2".split(): | |
client.wait_until_succeeds(f"ping -c 1 {addr}") | |
# 1200 pings * interval 0.1s + 5s of fudge = 125 seconds to send and receive all the pings | |
client.succeed(f"ping -c 1200 -i 0.1 -w 125 2001:db8::2") | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disable the firewall on the router or create a rule in the forward chain, that gets you a chunk further. The route selection is pretty stable here, it uses the
proto ra
default route.