Skip to content

Instantly share code, notes, and snippets.

@3isenHeiM
Last active July 27, 2022 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 3isenHeiM/46c847753f0894aab6c5baed4bb8cb27 to your computer and use it in GitHub Desktop.
Save 3isenHeiM/46c847753f0894aab6c5baed4bb8cb27 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)
# usage : ./mnds.sh <name_of_the_jail>
jexec -l ${1} pkg install --yes openmdns
jexec -l ${1} sysrc mdnsd_enable=yes
IFACE=$(jexec -l ${1} ifconfig | grep epair | head -n 1 | cut -f1 -d:)
jexec -l ${1} sysrc mdnsd_flags=${IFACE}
jexec -l ${1} service mdnsd start
freenas# jls
JID IP Address Hostname Path
...
5 - etherpad /mnt/basin/jails/etherpad
...
freenas# ./mdns.sh 5
Updating FreeBSD repository catalogue...
[etherpad] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
[etherpad] Fetching packagesite.txz: 100% 6 MiB 5.9MB/s 00:01
Processing entries: 100%
FreeBSD repository update completed. 25811 packages processed.
New version of pkg detected; it needs to be installed first.
The following 1 package(s) will be affected (of 0 checked):
Installed packages to be UPGRADED:
pkg: 1.9.4 -> 1.9.4_1
Number of packages to be upgraded: 1
2 MiB to be downloaded.
[etherpad] Fetching pkg-1.9.4_1.txz: 100% 2 MiB 2.6MB/s 00:01
Checking integrity... done (0 conflicting)
[etherpad] [1/1] Upgrading pkg from 1.9.4 to 1.9.4_1...
[etherpad] [1/1] Extracting pkg-1.9.4_1: 100%
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
openmdns: 0.6.15
libopenbsd: r298107
Number of packages to be installed: 2
The process will require 4 MiB more space.
2 MiB to be downloaded.
[etherpad] Fetching openmdns-0.6.15.txz: 100% 2 MiB 2.6MB/s 00:01
[etherpad] Fetching libopenbsd-r298107.txz: 100% 21 KiB 21.2kB/s 00:01
Checking integrity... done (0 conflicting)
[etherpad] [1/2] Installing libopenbsd-r298107...
[etherpad] [1/2] Extracting libopenbsd-r298107: 100%
[etherpad] [2/2] Installing openmdns-0.6.15...
===> Creating groups.
Creating group '_mdnsd' with gid '177'.
===> Creating users
Creating user '_mdnsd' with uid '177'.
[etherpad] [2/2] Extracting openmdns-0.6.15: 100%
mdnsd_enable: -> yes
mdnsd_flags: -> epair4b
Starting mdnsd.
ubuntu:~$ avahi-browse -a | grep etherpad
+ wlp7s0 IPv4 etherpad [epair4b:76:50:04:0a:98:fb] Workstation local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment