forked from mirrors_public/oddlama_nix-config
feat: enable ipv6 RA
This commit is contained in:
parent
cdd35390fb
commit
a543394fa8
6 changed files with 67 additions and 35 deletions
|
@ -57,9 +57,9 @@ in {
|
||||||
from = "all";
|
from = "all";
|
||||||
to = ["local"];
|
to = ["local"];
|
||||||
extraLines = [
|
extraLines = [
|
||||||
"ip6 nexthdr icmpv6 icmpv6 type { echo-request, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept"
|
"ip6 nexthdr icmpv6 icmpv6 type { echo-request, destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept"
|
||||||
"ip protocol icmp icmp type { echo-request, router-advertisement } accept"
|
"ip protocol icmp icmp type { echo-request, destination-unreachable, router-advertisement, time-exceeded, parameter-problem } accept"
|
||||||
#"ip6 saddr fe80::/10 ip6 daddr fe80::/10 udp dport 546 accept"
|
#"ip6 saddr fe80::/10 ip6 daddr fe80::/10 udp dport 546 accept" # (dhcpv6)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,10 +74,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.network = {
|
systemd.network.enable = true;
|
||||||
enable = true;
|
|
||||||
wait-online.anyInterface = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Rename known network interfaces
|
# Rename known network interfaces
|
||||||
extra.networking.renameInterfacesByMac = lib.mapAttrs (_: v: v.mac) (nodeSecrets.networking.interfaces or {});
|
extra.networking.renameInterfacesByMac = lib.mapAttrs (_: v: v.mac) (nodeSecrets.networking.interfaces or {});
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
{pkgs, ...}: {
|
{pkgs, ...}: {
|
||||||
|
systemd.network.wait-online.anyInterface = true;
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
tlp.enable = true;
|
tlp.enable = true;
|
||||||
physlock.enable = true;
|
physlock.enable = true;
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
"10-lan1" = {
|
"10-lan1" = {
|
||||||
DHCP = "yes";
|
DHCP = "yes";
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan1.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan1.mac;
|
||||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
networkConfig.IPv6PrivacyExtensions = "yes";
|
||||||
dhcpV4Config.RouteMetric = 10;
|
dhcpV4Config.RouteMetric = 10;
|
||||||
dhcpV6Config.RouteMetric = 10;
|
dhcpV6Config.RouteMetric = 10;
|
||||||
};
|
};
|
||||||
"10-wlan1" = {
|
"10-wlan1" = {
|
||||||
DHCP = "yes";
|
DHCP = "yes";
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wlan1.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wlan1.mac;
|
||||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
networkConfig.IPv6PrivacyExtensions = "yes";
|
||||||
dhcpV4Config.RouteMetric = 40;
|
dhcpV4Config.RouteMetric = 40;
|
||||||
dhcpV6Config.RouteMetric = 40;
|
dhcpV6Config.RouteMetric = 40;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
inherit (config.lib.net) cidr;
|
inherit (config.lib.net) cidr;
|
||||||
|
|
||||||
net.lan.ipv4cidr = "192.168.100.1/24";
|
net.lan.ipv4cidr = "192.168.100.1/24";
|
||||||
net.lan.ipv6cidr = "fd01::1/64";
|
net.lan.ipv6cidr = "fd00::1/64";
|
||||||
in {
|
in {
|
||||||
networking.hostId = nodeSecrets.networking.hostId;
|
networking.hostId = nodeSecrets.networking.hostId;
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ in {
|
||||||
networks = {inherit (config.systemd.network.networks) "10-wan";};
|
networks = {inherit (config.systemd.network.networks) "10-wan";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Create a MACVTAP for ourselves too, so that we can communicate with
|
||||||
|
# other taps on the same interface.
|
||||||
systemd.network.netdevs."10-lan-self" = {
|
systemd.network.netdevs."10-lan-self" = {
|
||||||
netdevConfig = {
|
netdevConfig = {
|
||||||
Name = "lan-self";
|
Name = "lan-self";
|
||||||
|
@ -30,6 +32,11 @@ in {
|
||||||
systemd.network.networks = {
|
systemd.network.networks = {
|
||||||
"10-lan" = {
|
"10-lan" = {
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan.mac;
|
||||||
|
# This interface should only be used from attached macvtaps.
|
||||||
|
# So don't acquire a link local address and only wait for
|
||||||
|
# this interface to gain a carrier.
|
||||||
|
networkConfig.LinkLocalAddressing = "no";
|
||||||
|
linkConfig.RequiredForOnline = "carrier";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
[Network]
|
[Network]
|
||||||
MACVTAP=lan-self
|
MACVTAP=lan-self
|
||||||
|
@ -39,35 +46,61 @@ in {
|
||||||
DHCP = "yes";
|
DHCP = "yes";
|
||||||
#address = [
|
#address = [
|
||||||
# "192.168.178.2/24"
|
# "192.168.178.2/24"
|
||||||
# "fd00::1/64"
|
# "fdee::1/64"
|
||||||
#];
|
#];
|
||||||
#gateway = [
|
#gateway = [
|
||||||
#];
|
#];
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wan.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wan.mac;
|
||||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
networkConfig.IPv6PrivacyExtensions = "yes";
|
||||||
dhcpV4Config.RouteMetric = 20;
|
linkConfig.RequiredForOnline = "routable";
|
||||||
dhcpV6Config.RouteMetric = 20;
|
|
||||||
};
|
};
|
||||||
"11-lan-self" = {
|
"20-lan-self" = {
|
||||||
address = [net.lan.ipv4cidr net.lan.ipv6cidr];
|
address = [net.lan.ipv4cidr net.lan.ipv6cidr];
|
||||||
matchConfig.Name = "lan-self";
|
matchConfig.Name = "lan-self";
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
IPForward = "yes";
|
IPForward = "yes";
|
||||||
IPv6PrivacyExtensions = "kernel";
|
IPv6PrivacyExtensions = "yes";
|
||||||
ConfigureWithoutCarrier = true;
|
IPv6SendRA = true;
|
||||||
};
|
};
|
||||||
dhcpV4Config.RouteMetric = 10;
|
# Announce a static prefix
|
||||||
dhcpV6Config.RouteMetric = 10;
|
ipv6Prefixes = [
|
||||||
|
{ipv6PrefixConfig.Prefix = cidr.canonicalize net.lan.ipv6cidr;}
|
||||||
|
];
|
||||||
|
# Delegate prefix from wan
|
||||||
|
#dhcpPrefixDelegationConfig = {
|
||||||
|
# UplinkInterface = "wan";
|
||||||
|
# Announce = true;
|
||||||
|
# SubnetId = "auto";
|
||||||
|
#};
|
||||||
|
# Provide a DNS resolver
|
||||||
|
ipv6SendRAConfig = {
|
||||||
|
EmitDNS = true;
|
||||||
|
# TODO change to self later
|
||||||
|
#DNS = cidr.ip net.lan.ipv6cidr;
|
||||||
|
DNS = ["2606:4700:4700::1111" "2001:4860:4860::8888"];
|
||||||
|
};
|
||||||
|
linkConfig.RequiredForOnline = "routable";
|
||||||
|
};
|
||||||
|
# Remaining macvtap interfaces should not be touched.
|
||||||
|
"90-macvtap-no-ll" = {
|
||||||
|
matchConfig.Kind = "macvtap";
|
||||||
|
networkConfig.LinkLocalAddressing = "no";
|
||||||
|
linkConfig.ActivationPolicy = "manual";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.nftables.firewall = {
|
networking.nftables.firewall = {
|
||||||
zones = lib.mkForce {
|
zones = lib.mkForce {
|
||||||
lan.interfaces = ["lan"];
|
lan.interfaces = ["lan-self"];
|
||||||
wan.interfaces = ["wan"];
|
wan.interfaces = ["wan"];
|
||||||
};
|
};
|
||||||
|
|
||||||
rules = lib.mkForce {
|
rules = lib.mkForce {
|
||||||
|
icmp = {
|
||||||
|
# accept ipv6 router solicit and multicast listener discovery query
|
||||||
|
extraLines = ["ip6 nexthdr icmpv6 icmpv6 type { mld-listener-query, nd-router-solicit } accept"];
|
||||||
|
};
|
||||||
|
|
||||||
masquerade-wan = {
|
masquerade-wan = {
|
||||||
from = ["lan"];
|
from = ["lan"];
|
||||||
to = ["wan"];
|
to = ["wan"];
|
||||||
|
@ -99,6 +132,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# TODO to microvm!
|
||||||
services.kea = {
|
services.kea = {
|
||||||
dhcp4 = {
|
dhcp4 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -112,19 +146,22 @@ in {
|
||||||
renew-timer = 1000;
|
renew-timer = 1000;
|
||||||
rebind-timer = 2000;
|
rebind-timer = 2000;
|
||||||
interfaces-config = {
|
interfaces-config = {
|
||||||
interfaces = ["lan"];
|
interfaces = ["lan-self"];
|
||||||
service-sockets-max-retries = -1;
|
service-sockets-max-retries = -1;
|
||||||
};
|
};
|
||||||
option-data = [
|
option-data = [
|
||||||
{
|
{
|
||||||
name = "domain-name-servers";
|
name = "domain-name-servers";
|
||||||
|
# TODO pihole self
|
||||||
data = "1.1.1.1, 8.8.8.8";
|
data = "1.1.1.1, 8.8.8.8";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
subnet4 = [
|
subnet4 = [
|
||||||
{
|
{
|
||||||
interface = "lan";
|
interface = "lan-self";
|
||||||
subnet = cidr.canonicalize net.lan.ipv4cidr;
|
subnet = cidr.canonicalize net.lan.ipv4cidr;
|
||||||
|
# TODO calculate this automatically, start at 40 or so
|
||||||
|
# to have enough for reservations
|
||||||
pools = [
|
pools = [
|
||||||
{pool = "192.168.100.20 - 192.168.100.250";}
|
{pool = "192.168.100.20 - 192.168.100.250";}
|
||||||
];
|
];
|
||||||
|
@ -134,6 +171,7 @@ in {
|
||||||
data = cidr.ip net.lan.ipv4cidr;
|
data = cidr.ip net.lan.ipv4cidr;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
# TODO reserve addresses for each VM
|
||||||
#reservations = [
|
#reservations = [
|
||||||
# {
|
# {
|
||||||
# duid = "aa:bb:cc:dd:ee:ff";
|
# duid = "aa:bb:cc:dd:ee:ff";
|
||||||
|
@ -144,13 +182,9 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#dhcp6 = {
|
|
||||||
# enable = true;
|
|
||||||
#};
|
|
||||||
};
|
};
|
||||||
systemd.services.kea-dhcp4-server.after = [
|
|
||||||
"sys-subsystem-net-devices-lan.device"
|
systemd.services.kea-dhcp4-server.after = ["sys-subsystem-net-devices-lan.device"];
|
||||||
];
|
|
||||||
|
|
||||||
#extra.wireguard.vms = {
|
#extra.wireguard.vms = {
|
||||||
# server = {
|
# server = {
|
||||||
|
|
|
@ -20,13 +20,13 @@ in {
|
||||||
"10-lan1" = {
|
"10-lan1" = {
|
||||||
DHCP = "yes";
|
DHCP = "yes";
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan1.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.lan1.mac;
|
||||||
networkConfig.IPv6PrivacyExtensions = "kernel";
|
networkConfig.IPv6PrivacyExtensions = "yes";
|
||||||
dhcpV4Config.RouteMetric = 10;
|
linkConfig.RequiredForOnline = "routable";
|
||||||
dhcpV6Config.RouteMetric = 10;
|
|
||||||
};
|
};
|
||||||
"10-wlan1" = {
|
"10-wlan1" = {
|
||||||
address = [net.iot.ipv4cidr net.iot.ipv6cidr];
|
address = [net.iot.ipv4cidr net.iot.ipv6cidr];
|
||||||
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wlan1.mac;
|
matchConfig.MACAddress = nodeSecrets.networking.interfaces.wlan1.mac;
|
||||||
|
linkConfig.RequiredForOnline = "no";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,10 @@
|
||||||
matchConfig.Name = vmCfg.linkName;
|
matchConfig.Name = vmCfg.linkName;
|
||||||
DHCP = "yes";
|
DHCP = "yes";
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
IPv6PrivacyExtensions = "kernel";
|
IPv6PrivacyExtensions = "yes";
|
||||||
ConfigureWithoutCarrier = true;
|
IPv6AcceptRA = true;
|
||||||
};
|
};
|
||||||
dhcpV4Config.RouteMetric = 20;
|
linkConfig.RequiredForOnline = "routable";
|
||||||
dhcpV6Config.RouteMetric = 20;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue