Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Accessing Plugin jails via their hostnames

Joined
Jan 25, 2015
Messages
26
I installed FreeNas yesterday and I think I've mostly got to grips with it at least for my basic setup. I've installed a few plugins and set them up, however I'd like to be able to access my plugin jails by their hostnames (e.g. sabnzbd:8080). The main reason for this is in case my DHCP lease expires or if I move my server to a new location - I'd like my plugins to be able to make API calls to other plugins without having to change the configuration if the IP changes for whatever reason (e.g. IP conflict on another network..).

For some reason I can't ping my jails by their hostnames from my laptop or from the freenas server, however I can ping them from the respective jail. (e.g. from my sabnzbd_3 jail, I can ping sabnzbd_3). I can ping the IP addresses of the jails just fine from anywhere on my network, I just can't ping them using their hostname. I've tried ping jailname, and ping jailname.servername, but no luck. Any ideas?
 

JoeVulture

Newbie
Joined
Sep 8, 2013
Messages
22
Each jail has its own hostname in /etc/hosts, which is why each jail can ping itself by hostname.
You could add entries for the IP addresses/names into the /etc/hosts file in each jail, but that doesn't let you change IP addresses around. To do that, you'll need a local DNS server to act as the central place for the IP address to hostname mapping.
Most routers have a built-in DNS server for use on your LAN; how you configure it is generally different from router to router.
 
Joined
Jan 25, 2015
Messages
26
Thanks for the info. Well I kind of assumed my router was already doing some DNS mapping as I can connect to my server by its hostname - how come it works for the server but not the jails?

That being said, it could just be that the reason I can access it by name is that the DNS entry is left over from my old unRaid install, which had the same name and IP address. So.. what steps would I need to take on the server to configure my router as the DNS server? Do I just set my router's IP addess as a Nameserver in "Global Configuration"?
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,031
Your FreeNAS server can be pinged because it broadcasts it's hostname using zeroconf. That is a service that let's a server share information with other machines that support it. Not all machines and jails support this. To configure DNS you need to make updates in your router not on FreeNAS. There might be a DNS option based on Mac address. This will be the settings you want to change.
 
Joined
Jan 25, 2015
Messages
26
Ah yes, sorry I got DNS the wrong way around somehow, I'm a little slow today! I'll look into that, although it sounds like setting up zeroconf in the jails may also be an option.. or does that cause issues?
 

JoeVulture

Newbie
Joined
Sep 8, 2013
Messages
22
To get the jails to see the main DNS server, you could just add to the list of nameservers.
In each jail, you'd need to add:
Code:
nameserver 1.2.3.4

to /etc/resolv.conf, where 1.2.3.4 is the IP address of your DNS server.
I believe that when a jail is created, the /etc/resolv.conf file is copied from the default system one.

That said, this may not be as flexible as you'd like. You can also try assigning the IP address settings for your jails via DHCP, which might pass down DNS server information (I don't know as I don't do it), but the MAC addresses of my jails seem to change once a day or so.

-- Joe
 

appliance

Newbie
Joined
Nov 6, 2019
Messages
67
NAT jails don't see each other hostname, even NAS itself. to cooperate between jails (e.g. sonarr <-> radarr <-> transmission) i pick non DHCP records and slap it to each jail hosts periodically:
Code:
iocage list -h | awk '{print $5 " " $2}' | grep -v "DHCP" > /tmp/hosts.jails
while read jail; do cp /tmp/hosts.jails /jails/jails/`cut -d' ' -f2 <<< $jail`/root/etc/hosts ; done < /tmp/hosts.jails

+ jail cooperation still works when router DNS is off
+ no need to setup local mdnsd or standalone IP addresses
 
Top