xref: /freebsd/share/examples/jails/README (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1# $FreeBSD$
2
3The below 4 samples require a VIMAGE enabled kernel:
4
5	# (as root)
6	$ cp VIMAGE /usr/src/sys/amd64/conf/
7	$ cd /usr/src
8	$ make KERNCONF=VIMAGE kernel
9	$ reboot
10
11FreeBSD 12 has VIMAGE enabled in GENERIC on amd64.
12In that case, for jng simply load the ng_ether module first
13(ng_bridge and ng_eiface will load on demand):
14
15	# (as root)
16	# Load the ng_ether module at boot:
17	$ sysrc kld_list+=ng_ether
18	# Load ng_ether at once without rebooting:
19	$ kldload ng_ether
20
21Sample 1: jail.conf(5)
22
23	$ cp jib jng /usr/sbin/
24	$ cat jail.xxx.conf >> /etc/jail.conf
25	$ vi /etc/jail.conf
26	# NB: Customize root directory and bridge interface
27	$ sysrc jail_enable=YES
28	# NB: Assumes jail_list="" (meaning ``all jails in jail.conf'')
29	# NB: Assumes rc_conf_files="" (``below rc.conf(5) samples not used'')
30	$ service jail start
31
32Sample 2: rc.conf(5)
33
34	$ cp jib jng /usr/sbin/
35	$ cp rc.conf.jails /etc/
36	$ vi /etc/rc.conf.jails
37	# NB: Customize root directory and bridge interface
38	$ sysrc rc_conf_files+=/etc/rc.conf.jails
39	# NB: Assumes /etc/jail.conf does not exist and jail_list=""
40	$ service jail start
41
42Sample 3: Per-jail jail.conf(5)
43
44	$ cp jib jng /usr/sbin/
45	$ cp jail.xxx.conf /etc/
46	$ vi /etc/jail.xxx.conf
47	# NB: Customize root directory and bridge interface
48	$ sysrc jail_enable=YES
49	$ sysrc jail_list+=xxx
50	# NB: Assumes rc_conf_files=""
51	$ service jail start
52
53Sample 4: Per-jail rc.conf(5)
54
55	$ cp jib jng /usr/sbin/
56	$ cp rcjail.xxx.conf /etc/
57	$ vi /etc/rcjail.xxx.conf
58	# NB: Customize root directory and bridge interface
59	$ sysrc jail_enable=YES
60	$ sysrc jail_list+=xxx
61	$ sysrc rc_conf_files+=/etc/rcjail.xxx.conf
62	# NB: Assumes neither /etc/jail.conf nor /etc/jail.xxx.conf exist
63	$ service jail start
64
65For additional recipes, see share/examples/netgraph for
66making and hooking together jails using netgraph as the
67virtual networking fabric.
68