Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ip_hostname option when creating a jail #702

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/chapters/subcommands/create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ Also, uname does not work from within a jail. Much like MOTD, it gives you the
information about the host system instead of the jail. If you need to check the version
of freebsd running on the jail use the freebsd-version command to get accurate information.

Besides providing an IP address, the following options are also valid:

- SLAAC
- DHCP
- ip_hostname

If VNET is enabled, and the ``SLAAC`` or ``DHCP`` option are specified, the interface is
automatically configured to make use of these.

If the ``ip_hostname`` option is specified, the jail will resolve the *hostname* to
obtain the IP address(es). See `jail(8) <https://man.freebsd.org/cgi/man.cgi?jail>`_
for additional details.
9 changes: 7 additions & 2 deletions usr/local/share/bastille/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ validate_name() {
}

validate_ip() {
ipx_addr="ip4.addr"
ip="$1"
ip6=$(echo "${ip}" | grep -E '^(([a-fA-F0-9:]+$)|([a-fA-F0-9:]+\/[0-9]{1,3}$)|SLAAC)')
if [ -n "${ip6}" ]; then
info "Valid: (${ip6})."
ipx_addr="ip6.addr"
IP6_MODE="new"
elif [ "${ip}" = "ip_hostname" ]; then
info "Valid: (${ip})."
IP_HOSTNAME="ip_hostname;"
else
ipx_addr="ip4.addr"
if [ "${ip}" = "DHCP" ]; then
info "Valid: (${ip})."
else
Expand All @@ -101,7 +104,7 @@ validate_ip() {
fi
fi
fi
if echo "${ip}" | grep -qvE '(SLAAC|DHCP|0[.]0[.]0[.]0)'; then
if echo "${ip}" | grep -qvE '(SLAAC|DHCP|ip_hostname|0[.]0[.]0[.]0)'; then
if [ "${ipx_addr}" = "ip4.addr" ]; then
IP4_ADDR="${ip}"
IP4_DEFINITION="${ipx_addr} = ${ip};"
Expand All @@ -117,6 +120,7 @@ validate_ips() {
IP6_DEFINITION=""
IP4_ADDR=""
IP6_ADDR=""
IP_HOSTNAME=""
for ip in ${IP}; do
validate_ip "${ip}"
done
Expand Down Expand Up @@ -186,6 +190,7 @@ ${NAME} {
osrelease = ${RELEASE};

interface = ${bastille_jail_conf_interface};
${IP_HOSTNAME}
${IP4_DEFINITION}
${IP6_DEFINITION}
ip6 = ${IP6_MODE};
Expand Down