"hosts" file for jails (ezjail)

Perry Hutchison perryh at pluto.rain.com
Mon Aug 25 07:11:15 UTC 2014


Erich Dollansky <erichsfreebsdlist at alogt.com> wrote:
> On Sun, 24 Aug 2014 21:35:29 -0400
> Stephen Cook <sclists at gmail.com> wrote:
> > Is there a way to get a bunch of jails (I'm using ezjail) to share
> > the same hosts file, preferably one stored somewhere on the host OS?
> > ...
> > I'd like to be able to update the file when I add a new jail, and
> > have the others able to connect to it by whatever stupid name I give
> > it, without editing all those different hosts files. But I suspect
> > the whole point of jails being kept separate from the host filesystem
> > might be in my way.
>
> what you want is against the idea of jails.

Indeed.  OTOH one of the longstanding strengths of Unix -- and
the motivation for "mechanism, not policy" -- is that mechanisms
can often be cleverly used in ways that their designers did not
anticipate.

> What you can do, creates in the root filesystem the hosts file
> and write a script which copies it then into the jails.

That (and variants, such as using puppet to maintain the jails'
configuration files) is likely the most general approach.

In the particular case where all of the jails are contained
within the same host filesystem, it should also be possible
to use hardlinks (so that all the jails share the same inode).
Granted this would enable any jail to overwrite what the others
see -- which may or may not be acceptable in the OP's situation.


More information about the freebsd-questions mailing list