View Source MdnsLite.Options (mdns_lite v0.8.11)

MdnsLite options

MdnsLite is usually configured in a project's application environment (config.exs) as follows:

config :mdns_lite,
  hosts: [:hostname, "nerves"],
  ttl: 120,

  instance_name: "mDNS Lite Device",

  services: [
    %{
      id: :web_server,
      protocol: "http",
      transport: "tcp",
      port: 80,
      txt_payload: ["key=value"]
    },
    %{
      id: :ssh_daemon,
      instance_name: "More particular mDNS Lite Device"
      protocol: "ssh",
      transport: "tcp",
      port: 22
    }
  ]

The configurable keys are:

  • :hosts - A list of hostnames to respond to. Normally this would be set to :hostname and mdns_lite will advertise the actual hostname with .local appended.
  • :ttl - The default mDNS record time-to-live. The default of 120 seconds is probably fine for most use. See RFC 6762 - Multicast DNS for considerations.
  • instance_name - A user friendly name that will be used as the name for this device's advertised service(s). Per RFC6763 Appendix C, this should describe the user-facing purpose or description of the device, and should not be considered a unique identifier. For example, 'Nerves Device' and 'MatCo Laser Printer Model CRM-114' are good choices here. If instance_name is not defined it defaults to the first entry in the hosts list
  • :excluded_ifnames - A list of network interfaces names to ignore. By default, mdns_lite will ignore loopback and cellular network interfaces.
  • :ipv4_only - Set to true to only respond on IPv4 interfaces. Since IPv6 isn't fully supported yet, this is the default. Note that it's still possible to get AAAA records when using IPv4.
  • :if_monitor - Set to MdnsLite.VintageNetMonitor when using Nerves or MdnsLite.InetMonitor elsewhere. The default is MdnsLite.VintageNetMonitor.
  • :dns_bridge_enabled - Set to true to start a DNS server running that will bridge DNS to mDNS.
  • :dns_bridge_ip - The IP address for the DNS server. Defaults to 127.0.0.53.
  • :dns_bridge_port - The UDP port for the DNS server. Defaults to 53.
  • :dns_bridge_recursive - If a regular DNS request comes on the DNS bridge, forward it to a DNS server rather than returning an error. This is the default since there's an issue on Linux and Nerves that prevents Erlang's DNS resolver from checking the next one.
  • :services - A list of services to advertise. See MdnsLite.service for details.

Some options are modifiable at runtime. Functions for modifying these are in the MdnsLite module.

Summary

Functions

Normalize a service description

Functions

Link to this function

normalize_service(service)

View Source
@spec normalize_service(MdnsLite.service()) ::
  {:ok, MdnsLite.service()} | {:error, String.t()}

Normalize a service description

All service descriptions are normalized before use. Call this function if you're unsure how the service description will be transformed for use.