devel.reinikainen.net
HomeDocumentsCodeBugtrackerSearchreinikainen.netJB Consulting
Home arrow Shell scripts arrow FreeBSD jailsetup
FreeBSD jailsetup PDF Print
User Rating: / 2
PoorBest 
Written by Jani Reinikainen   
Nov 11, 2007 at 06:52 PM

jailsetup.sh

This is the basic script for setting up jail environments in FreeBSD 5.x, almost verbatim from the jail man page, except with a few additions and compiler optimizations. Each jail created by this script is about 100Mb using the default settings. Your best bet is to install all sources on the host system (using /stand/sysinstall, for example) before running this script, otherwise you might run into the 'Don't know how to make world' error.

jailsetup-ssh.sh

Designed to create a relatively limited jail for Telnet/SSH shell accounts in FreeBSD 5.0-RELEASE. This needs more work, but should give you a good base for further development.

Usage

For example:

# chmod +x jailsetup.sh
# ./jailsetup.sh 10.0.0.20
# mount_nullfs /usr/ports /usr/jail/10.0.0.20/usr/ports
# jail /usr/jail/10.0.0.20 hostname /bin/sh 

Notes

Once you've got one, clean, jail cell set up, it might be a good idea to just copy it as many times as you need cells, as make world takes quite a while, even on higher-end computers. Read man jail for more information. I have only tested these scripts in Bash and csh.

Copyright © 2007 Jani Reinikainen. All rights reserved.
Permission granted to replicate information found on these pages, provided that all copyright headers/footers remain intact.