Last active
December 12, 2023 18:54
-
-
Save jack828/b8375b16b6fb9eae52201d4deb563ab7 to your computer and use it in GitHub Desktop.
TrueNAS Jail mDNS Setup Kickstarter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An explanation of this script is available on my blog https://jackburgess.dev/blog/truenas-jails-access-via-mdns | |
# This allows you a nice way of connecting to your jails via their hostname using mDNS | |
# e.g. for Netdata, which runs on port 3000, you can access it on your jail via: | |
# http://<jail ip>:3000/ | |
# But wouldn't it be nice to access it on | |
# http://jailhostname.local/ | |
# | |
# Oneliner to kickstart | |
# pkg install -y curl && curl --silent https://gist.githubusercontent.com/jack828/b8375b16b6fb9eae52201d4deb563ab7/raw | /bin/sh -s PORT | |
PORT=$1 | |
HOSTNAME=$(hostname) | |
echo "Installing services..." | |
pkg install -y avahi-app socat | |
sysrc dbus_enable="YES" | |
sysrc avahi_daemon_enable="YES" | |
sysrc socat_enable="YES" | |
rm /usr/local/etc/avahi/services/*.service | |
cat > /usr/local/etc/avahi/services/http.service << EOF | |
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name replace-wildcards="yes">%h</name> | |
<service> | |
<type>_http._tcp</type> | |
<port>80</port> | |
</service> | |
</service-group> | |
EOF | |
cat >> /usr/local/etc/socat-instances.conf << EOF | |
[jailredirect] | |
daemonuser=root | |
flags="tcp-listen:80,reuseaddr,fork tcp:localhost:$PORT" | |
EOF | |
echo "Starting services..." | |
service dbus start | |
service avahi-daemon start | |
service socat start jailredirect | |
echo "Done! You can now access your jail service on http://$HOSTNAME.local/" |
Hey @Erdack54, if you have it on a fresh jail you can simply delete the jail.
Otherwise, you can just
pkg delete -y avahi-app socat
sysrc dbus_enable="NO"
sysrc avahi_daemon_enable="NO"
sysrc socat_enable="NO"
Otherwise, I need more information to help you.
@jack828 Thank you for your quick response, I'm going to spend a little more time looking because I have another problem at the same time a little more important, TrueNAS becomes totally inaccessible after 30m :/ I'll come back to you if it concerns your script, have a good day 🙂
@Erdack54 No problem. I did have an issue that cleared itself eventually wherein socat
consumed a lot of CPU and locked me out. Do let me know how you get on!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how i can revert this ? It's seem not working anymore :/