summaryrefslogtreecommitdiff
path: root/common/net.nix
diff options
context:
space:
mode:
Diffstat (limited to 'common/net.nix')
-rw-r--r--common/net.nix36
1 files changed, 36 insertions, 0 deletions
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 <hostname>.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;
+ };
+ };
+ };
+}