Most if not all of the tutorials I have found have you recompile the system into a new directory like the section6 wiki. This just seems overly complicated and hard to do especially if you are in a pinch for time. Getting ready for a security competition my partner Sean Jordan introduced me to the sysinstall method of making jails.
When making partitions I like to create a /jail partition to give the jails their own partition. I suggest making it at least 2 gigs for each jail. Also remember all the files used by the users / services in the jail need to be on that partition so size it accordingly. Each jail needs it's own ip address, for my set up I am behind a router running nat using the subnet 172.16.67.0/24.
Once FreeBSD is installed start making the needed directories.
- mkdir /jail/master
- mkdir /jail/master/usr/
- cp -R /bin/ /jail/master/bin
- cp -R /etc/ /jail/master/etc
- cp -R /lib/ /jail/master/lib
- cp -R /libexec/ /jail/master/libexec
- cp -R /sbin/ /jail/master/sbin
- cp -R /usr/share /jail/master/usr/share
- cp -R /usr/bin /jail/master/usr/bin
- cp -R /usr/sbin /jail/master/usr/sbin
- cp -R /usr/lib /jail/master/usr/lib
- chroot /jail/master /bin/csh
- /usr/sbin/sysinstall
- Configure
- Distributions
- base
- (use ftp for media source)
- exit sysinstall
- exit
- cp -R /jail/master/ /jail/ssh
- cp -R /jail/master/ /jail/dns
- vi /etc/rc.conf
- ifconfig_lnc0_alias0="172.16.67.47 netmask 255.255.255.0" #Add alias for your network
- ifconfig_lnc0_alias1="172.16.67.48 netmask 255.255.255.0" #Add alias for your network
- jail_enable="YES" # Set to NO to disable starting of any jails
- jail_list="ssh dns" # Space separated list of names of jails
- jail_set_hostname_allow="NO" # Allow root user in a jail to change its hostname
- jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail
- jail_ssh_rootdir="/jail/ssh"
- jail_ssh_hostname="ssh.bsd.local"
- jail_ssh_ip="172.16.67.47"
- jail_ssh_exec_start="/bin/sh /etc/rc"
- jail_ssh_devfs_enable="YES"
- jail_ssh_devfs_ruleset="devfsrules_jail"
- jail_dns_rootdir="/jail/dns"
- jail_dns_hostname="dns.bsd.local"
- jail_dns_ip="172.16.67.48"
- jail_dns_exec_start="/bin/sh /etc/rc"
- jail_dns_devfs_enable="YES"
- jail_dns_devfs_ruleset="devfsrules_jail"
- sh /etc/rc
- JID IP Address Hostname Path
- 2 172.16.67.48 dns.bsd.local /jail/dns
- 1 172.16.67.47 ssh.bsd.local /jail/ssh
- lnc0: flags=108843
mtu 1500 - inet6 fe80::20c:29ff:fe3c:1ce8%lnc0 prefixlen 64 scopeid 0x1
- inet 172.16.67.46 netmask 0xffffff00 broadcast 172.16.67.255
- inet172.16.67.47 netmask 0xffffff00 broadcast 172.16.67.255
- inet 172.16.67.48 netmask 0xffffff00 broadcast 172.16.67.255
To enter a jail use jexec
- jexec 1 /usr/local/bin/bash
To stop all running jails run
- /etc/rc.d/jail stop
- pkill -j JID
- security.jail.allow_raw_sockets=1
3 comments:
thanks for sharing this site. you can download lots of ebook from here
http://feboook.blogspot.com
To stop just 1 jail run
1. pkill -j JID
Or /etc/rc.d/jail stop JAIL_NAME
:-)
Hi there. I am about to chroot into/jail/master and run sysinstall. When come to FTP transfer process it can be transfer. I also try to use other servers and the result is same. Please advice. Thanks in advance
Post a Comment