blob: 9341245db614898ab7fb330b6e30d43a545446f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
};
};
};
}
|