Org Web Adapter

pages/creating_a_new_iocage_jail_in_freebsd.org

ID
d06f8911-ed39-4c02-a935-6dcf3ad7c308

Creating a New Iocage Jail in FreeBSD

- tags :: FreeBSD Tutorials Jails Iocage

Steps

Create the jail with iocage

#+begin_src sh

iocage create -n "mail" -r latest vnet="on" allow_raw_sockets="1" boot="on" bpf="yes" dhcp="on"

#+end_src

Copy jails public key to iocage root

#+BEGIN_SRC sh

ssh rhea.local

sudo su

mkdir /zroot/iocage/jails/<jail-name>/root/root/.ssh

cp /home/powellc/.ssh/jails.pub /zroot/iocage/jails/<jail-name>/root/root/.ssh/authorized_keys

#+END_SRC

Enable ssh and root login over ssh

#+begin_src sh enable ssh root login

sysrc sshd_enable="YES"

vi /etc/ssh/sshd_config

#+end_src

#+begin_src diff add root login to sshd

-#PermitRootLogin no

+PermitRootLogin yes

#+end_src

#+begin_src sh start services

service sshd start

#+end_src

Run ansible against the new IP address

1. Add ip address to [jails] ansible group

2. `ansible-playbook playbook.yml --limit=<ip address>`

3. Update ansible [jails] group with .local DNS for iocage container

4. Add hostname to whatever roles you want this container to run

If not using ansible, install avahi and dbus to get local dns working

ID
76932902-eb88-11ea-ad6c-e86a64ecc701

#+begin_src sh install and enable apps

pkg install -y avahi-app nss_mdns dbus

sysrc dbus_enable="YES"

sysrc avahi_daemon_enable="YES"

sysrc sshd_enable="YES"

vi /etc/nsswitch.conf

#+end_src

#+begin_src diff add mdns to nsswitch config

-hosts: files dns

+hosts: files dns mdns

#+end_src

#+begin_src sh enable ssh root login

vi /etc/ssh/sshd_config

#+end_src

#+begin_src diff add root login to sshd

-#PermitRootLogin no

+PermitRootLogin yes

#+end_src

#+begin_src sh start services

service dbus start

service avahi-daemon start

service sshd start

#+end_src

Finally, ssh in and install whatever packages you need for this jail service