Skip to content

Instantly share code, notes, and snippets.

@KlfJoat
Forked from 3isenHeiM/MDNS_jail_FreeNAS
Last active July 27, 2022 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KlfJoat/dd675e7052fadbd41481d350825ae3b9 to your computer and use it in GitHub Desktop.
Save KlfJoat/dd675e7052fadbd41481d350825ae3b9 to your computer and use it in GitHub Desktop.
Enable MDNS on a FreeNAS/BSD jail. That will allow a Avahi name resolution of the jail in the local network.
#!/bin/sh
# This script is to be executed on the FreeNAS/BSD host itself (and not inside the jail)
# Warning: The proper space-delimited interface(s) must be passed in mdnsd_flags or it will not work.
# usage : ./mnds.sh <jail name or jid>
pkg -j ${1} install --yes openmdns
sysrc -j ${1} mdnsd_enable=yes
#IFACE=$(jexec -l ${1} ifconfig | grep epair | head -n 1 | cut -f1 -d:) # This assumes different networking than I use.
IFACE=$(ifconfig -l -u | sed -e 's/[[:space:]]lo.[[:space:]]*//g') # Why use 3 pipes when the base command will format it for you?
sysrc -j ${1} mdnsd_flags="${IFACE}"
service -j ${1} mdnsd start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment