Articles

Names for jails

The jails of a project find each other by name. db.shop.internal, or just db, and the names follow what runs: nothing to write, nothing to keep in step.

The idea

A name instead of an address.

The jails of a project reach each other by name. A jail called db in the project shop is db.shop.internal: the jail, the project, and internal.

Nothing to write down and nothing to keep in step. When the address of a jail changes, its name still leads to it.

The short name

Inside the project, the project is understood.

A jail says just db. Its resolver adds the project for you, so the short name and the long one reach the same jail:

from the web jail
$ jailops exec web -- ping -c 1 db
$ jailops exec web -- ping -c 1 db.shop.internal

Use the short name in what the jail runs, and the long one when you talk about a jail from outside its project.

The host

One name for the machine.

The host as the jails of a project see it is host.shop.internal, or just host. It is the address of the host on their network: where the resolver, a package mirror or a log collector on the host is.

IPv4, IPv6 or both

Three names for each jail.

A name without a label has both kinds of address. Put v4 or v6 in front of the project to ask for one:

  • db.shop.internal: IPv4 and IPv6, whatever the jail has.
  • db.v4.shop.internal: the IPv4 address only.
  • db.v6.shop.internal: the IPv6 address only.

A jail that has only IPv6 has the first and the last. The host answers to host and host.v4.

The names follow what runs

Create it, and it is there.

A jail that runs has a name. Start one, create one, rename one, stop or delete one, and the names change by themselves, within moments:

on the host
$ jailops create cache --image freebsd-15-1 --network lan --storage default --start
$ jailops exec web -- ping -c 1 cache

A stopped jail has no name, and a deleted one has none for good. Nothing is left to clean up.

Only your own project

Projects keep their names to themselves.

A jail sees the names of its own project and of no other. A jail in shop that asks for postgres.blog.internal gets no answer, and the other way round. Everything else a resolver knows, example.org and the rest of the internet, works as always.

It follows the idea that a project is a boundary. Between projects you use addresses, and a firewall rule says who may reach whom.

Nothing to set up

If the host runs local-unbound.

The names are answered by the resolver of the host, the base system's local-unbound. jailops-setup offers to turn it on when you set the host up, and from then on there is nothing to configure: JailOps hands the resolver the names, and the jails ask the host.

To see where you stand:

on the host
$ jailops doctor | grep dns

It says not used until the host resolver is on, and what is missing, with the one command that fixes it, when something is.

Whether the resolver of the host asks other resolvers or finds the answers from the root servers itself is the business of that resolver, and its own documentation says how to change it.

An example

A web jail and its database.

The database jail is called db. The web jail asks for it by name, in a command and in its configuration:

from the web jail
$ jailops exec web -- psql -h db -U web shop

# in the configuration of the web application
DATABASE_URL=postgres://web@db:5432/shop

If the database jail is rebuilt and gets another address, nothing in the web jail changes. Add a rule that lets the web jail in (jailops app allow db --from jail:web) and the name does the rest.

Why .internal

A name that stays yours.

.internal is set aside for private use and never becomes a name on the internet, so it can never lead somewhere else. .local would not work: that is multicast DNS, and a resolver sends it out on the network instead of asking the host.

See also

More articles

Try it on one server.

Try the console from the screenshots, install on a clean FreeBSD 15.1 machine, or add JailOps to a host you already run.