nixos/home: Keep untrusted to the Internet
The routers reject new connections from the `untrusted` VLAN to internal destinations before the firewall's ICMP rules, then allow Internet transit via `wan` and `as211024`. The shared `lib.my.c.internalNets` also covers the modem's management subnet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,11 +94,9 @@ in
|
||||
|
||||
configuration = { lib, pkgs, config, assignments, allAssignments, ... }:
|
||||
let
|
||||
inherit (lib) mkIf mkMerge mkForce optionalString concatStringsSep;
|
||||
inherit (lib) mkIf mkMerge mkForce;
|
||||
inherit (lib.my) mkOpt' networkdAssignment;
|
||||
inherit (lib.my.c) networkd;
|
||||
|
||||
cfg = config.my.homeRouter;
|
||||
in
|
||||
{
|
||||
imports = map (m: import m index) [
|
||||
@@ -116,10 +114,6 @@ in
|
||||
Broadcast addresses to exclude when auto-selecting the router's own `wan` A record,
|
||||
for extra static subnets that share the `wan` interface.
|
||||
'';
|
||||
firewall.untrustedRejectV4 = mkOpt' (listOf str) [ ] ''
|
||||
IPv4 prefixes untrusted clients must be explicitly rejected from reaching. Only needed
|
||||
for subnets sharing the `wan` interface, since `wan` egress is otherwise accepted.
|
||||
'';
|
||||
};
|
||||
|
||||
config = {
|
||||
@@ -365,10 +359,16 @@ in
|
||||
meta l4proto udp ct state new jump routing-udp
|
||||
return
|
||||
}
|
||||
# `untrusted` gets the Internet only: colony trusts all home prefixes across the
|
||||
# mesh, and many devices trust anything on the LAN. Runs before `forward`, whose
|
||||
# ICMP rules would otherwise let pings through.
|
||||
chain untrusted-internal {
|
||||
ct state established,related return
|
||||
${lib.my.c.internalNets.nftReject}
|
||||
}
|
||||
chain filter-untrusted {
|
||||
${optionalString (cfg.firewall.untrustedRejectV4 != [ ]) "ip daddr { ${concatStringsSep ", " cfg.firewall.untrustedRejectV4} } reject"}
|
||||
oifname wan accept
|
||||
return
|
||||
oifname { wan, as211024 } accept
|
||||
reject with icmpx admin-prohibited
|
||||
}
|
||||
|
||||
chain forward-early {
|
||||
@@ -380,11 +380,13 @@ in
|
||||
# More Disney+ discrimination...
|
||||
# TODO: This prefix could change (random AWS block)
|
||||
ip6 daddr 2600:9000:2245::/48 drop
|
||||
|
||||
iifname lan-untrusted jump untrusted-internal
|
||||
}
|
||||
chain forward {
|
||||
${lib.my.c.as211024.nftTrust}
|
||||
iifname lan-untrusted jump filter-untrusted
|
||||
iifname { wan, as211024, lan-untrusted } oifname { lan-hi, lan-lo } jump filter-routing
|
||||
iifname { wan, as211024 } oifname { lan-hi, lan-lo } jump filter-routing
|
||||
oifname as211024 accept
|
||||
}
|
||||
chain output { }
|
||||
|
||||
@@ -203,11 +203,8 @@
|
||||
};
|
||||
server.enable = true;
|
||||
# The modem's management subnet shares the `wan` interface: skip its address when
|
||||
# picking our own wan A record, and reject untrusted clients from reaching it.
|
||||
homeRouter = {
|
||||
dns.wanSkipBroadcasts = [ (lib.my.netBroadcast prefixes.modem.v4) ];
|
||||
firewall.untrustedRejectV4 = [ prefixes.modem.v4 ];
|
||||
};
|
||||
# picking our own wan A record
|
||||
homeRouter.dns.wanSkipBroadcasts = [ (lib.my.netBroadcast prefixes.modem.v4) ];
|
||||
# deploy.node.hostname = "192.168.68.2";
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user