From a4c50351f5d55438a102d48c63dcbb62f9ef5e8d Mon Sep 17 00:00:00 2001 From: "Henry J. Webster" Date: Tue, 4 Aug 2026 17:10:10 -0500 Subject: networking: expose Ollama and mDNS on Wi-Fi LAN Serve Ollama on kusanagi's Wi-Fi LAN while removing the blanket tailscale0 firewall trust so tailnet traffic follows explicit host firewall rules instead of inheriting every listening service. Add shared LAN networking for both hosts: allow ping, publish and resolve .local names with Avahi, and scope mDNS to each machine's declared Wi-Fi interface. Assisted-by: OpenAI:gpt-5 --- common/core.nix | 4 ++-- common/default.nix | 1 + common/net.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 common/net.nix (limited to 'common') diff --git a/common/core.nix b/common/core.nix index 5d36646..9e9ca7a 100644 --- a/common/core.nix +++ b/common/core.nix @@ -16,8 +16,8 @@ # Enable networking networking.networkmanager.enable = true; - # for tailscale - networking.firewall.trustedInterfaces = [ "tailscale0" ]; + # for tailscale; open only its discovery/connection UDP port and let the + # normal host firewall rules apply to tailnet traffic too. networking.firewall.allowedUDPPorts = [ 41641 ]; services.tailscale.enable = true; diff --git a/common/default.nix b/common/default.nix index 946b3a7..e5bffc0 100644 --- a/common/default.nix +++ b/common/default.nix @@ -5,5 +5,6 @@ { imports = [ ./core.nix + ./net.nix ]; } diff --git a/common/net.nix b/common/net.nix new file mode 100644 index 0000000..9341245 --- /dev/null +++ b/common/net.nix @@ -0,0 +1,36 @@ +# LAN reachability and mDNS discovery shared by all machines. +{ + config, + lib, + ... +}: + +let + cfg = config.lanDiscovery; +in +{ + options.lanDiscovery.interface = lib.mkOption { + type = lib.types.str; + description = "Wi-Fi LAN interface used for mDNS discovery."; + }; + + config = { + # Allow IPv4 ICMP echo requests so hosts can be found with ping. + networking.firewall.allowPing = true; + + # Avahi/mDNS: publish .local and resolve other *.local LAN names. + # Keep the multicast DNS firewall opening scoped to the host's Wi-Fi LAN interface. + networking.firewall.interfaces.${cfg.interface}.allowedUDPPorts = [ 5353 ]; + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = false; + allowInterfaces = [ cfg.interface ]; + publish = { + enable = true; + addresses = true; + workstation = true; + }; + }; + }; +} -- cgit v1.3