Compare commits

...

2 commits

Author SHA1 Message Date
Patrick d2702099b0
WIP: wifi 2025-01-02 23:35:11 +01:00
Patrick 690f98b0a6
broken: nft filter own packets 2025-01-02 22:04:16 +01:00
5 changed files with 62 additions and 14 deletions

View file

@ -5,7 +5,6 @@
}: }:
{ {
networking = { networking = {
search = [ "local" ];
useNetworkd = true; useNetworkd = true;
dhcpcd.enable = false; dhcpcd.enable = false;
useDHCP = false; useDHCP = false;
@ -42,5 +41,4 @@
MulticastDNS=true MulticastDNS=true
''; '';
}; };
} }

View file

@ -16,7 +16,9 @@
intel2200BGFirmware intel2200BGFirmware
]; ];
boot.kernel.sysctl."net.ipv4.ip_forward" = 1; boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
networking.nftables.firewall.zones.untrusted.interfaces = [ "lan-services" ]; networking.nftables.firewall.zones.untrusted.interfaces = [
"lan-home"
];
hardware.wirelessRegulatoryDatabase = true; hardware.wirelessRegulatoryDatabase = true;
# systemd.network = { # systemd.network = {
# netdevs."40-wifi-home" = { # netdevs."40-wifi-home" = {
@ -40,15 +42,15 @@
# }; # };
# }; # };
networking.nftables.firewall.zones.wlan.interfaces = [ "wlan1" ]; # networking.nftables.firewall.zones.wlan.interfaces = [ "wlan1" ];
networking.nftables.firewall.zones.home.interfaces = [ "lan-home" ]; # networking.nftables.firewall.zones.home.interfaces = [ "lan-home" ];
networking.nftables.firewall.rules.wifi-forward = { networking.nftables.firewall.rules.wifi-forward = {
from = [ "wlan" ]; from = [ "wlan" ];
to = [ "lan-home" ]; to = [ "home" ];
verdict = "accept"; verdict = "accept";
}; };
systemd.network.networks."40-wifi" = { systemd.network.networks."40-wifi" = {
matchConfig.Name = "lan-home"; matchConfig.Name = "wlan1";
address = [ address = [
(lib.net.cidr.hostCidr (globals.services.hostapd.ip + 1) globals.net.vlans.home.cidrv4) (lib.net.cidr.hostCidr (globals.services.hostapd.ip + 1) globals.net.vlans.home.cidrv4)
(lib.net.cidr.hostCidr (globals.services.hostapd.ip + 1) globals.net.vlans.home.cidrv6) (lib.net.cidr.hostCidr (globals.services.hostapd.ip + 1) globals.net.vlans.home.cidrv6)

View file

@ -112,9 +112,8 @@ in
// mkContainer "nginx" { } // mkContainer "nginx" { }
// mkMicrovm "hostapd" { // mkMicrovm "hostapd" {
vlans = [ vlans = [
"guests" # "guests"
"home" "home"
"services"
]; ];
}; };
} }

View file

@ -8,6 +8,12 @@ let
cfg = { cfg = {
interfaces = "lan-.*"; interfaces = "lan-.*";
rules = [ rules = [
{
from = ".*";
to = "lan-home";
allow_questions = "";
allow_answers = ".*";
}
{ {
from = "lan-home"; from = "lan-home";
to = "lan-services"; to = "lan-services";
@ -15,10 +21,10 @@ let
allow_answers = ""; allow_answers = "";
} }
{ {
from = "lan-services"; from = "lan-home";
to = "lan-home"; to = "lan-devices";
allow_questions = ""; allow_questions = "(printer|ipp)";
allow_answers = "(nucnix|elisabeth)"; allow_answers = "";
} }
]; ];
}; };
@ -28,7 +34,7 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; after = [ "network.target" ];
#environment.RUST_LOG = "debug"; environment.RUST_LOG = "debug";
serviceConfig = { serviceConfig = {
Restart = "on-failure"; Restart = "on-failure";

43
patches/PR/370347.diff Normal file
View file

@ -0,0 +1,43 @@
diff --git a/nixos/modules/services/networking/networkd-dispatcher.nix b/nixos/modules/services/networking/networkd-dispatcher.nix
index 49d5cd545656a..5e307d81624ee 100644
--- a/nixos/modules/services/networking/networkd-dispatcher.nix
+++ b/nixos/modules/services/networking/networkd-dispatcher.nix
@@ -102,21 +102,23 @@ in
services.networkd-dispatcher.extraArgs =
let
- scriptDir = pkgs.symlinkJoin {
- name = "networkd-dispatcher-script-dir";
- paths = lib.mapAttrsToList (
- name: cfg:
- (map (
- state:
- pkgs.writeTextFile {
- inherit name;
- text = cfg.script;
- destination = "/${state}.d/${name}";
- executable = true;
- }
- ) cfg.onState)
- ) cfg.rules;
- };
+ scriptDir = pkgs.runCommand "networkd-dispatcher-script-dir" { } ''
+ mkdir $out
+ ${lib.concatStrings (
+ lib.mapAttrsToList (
+ name: cfg:
+ (lib.concatStrings (
+ map (state: ''
+ mkdir -p $out/${state}.d
+ ln -s ${
+ pkgs.writeShellApplication {
+ inherit name;
+ text = cfg.script;
+ }
+ }/bin/${name} $out/${state}.d/${name}'') cfg.onState
+ ))
+ ) cfg.rules
+ )}'';
in
[
"--verbose"