This document describes some guidelines and tips I've used for many of my FreeBSD installations. It is the result of over two years of direct experience installing and configuring some 50+ FreeBSD servers. Almost all of these installs were based on the 4.x STABLE or RELEASE branches, so if you're looking at CURRENT or older branches (e.g. 3.x) then this guide probably won't help you much.
This article is not meant to be a guide for newbies to the FreeBSD world. If you fall into this category, read the FreeBSD Handbook and consider the book Absolute BSD by Michael Lucas.
Instead, this article is intending to complement the official handbook.
* THIS DOCUMENT IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR (MARK FOSTER OR * ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE.
Media - what media will you install from? I use 4.8 Release CD-ROM but an FTP install gives you the "latest and greatest" from the stable branch.
In the early days I would often install from the boot/root floppies and then choose the FTP method from there. This is a perfectly reasonable way to install FreeBSD if you like the -STABLE branch and have the bandwidth. Where as a CD-ROM install can take 10-15 minutes, the FTP method will take upwards of an hour even on a fast pipe.
Partitioning - it's important to know what size your disks are before you start, and
knowing what the box will do (email server, web server, etc).
Define your smaller and more active partitions eg. swap, /var) first so that
they are closer to the outer/faster part of the drive. If you have multiple
disks split your swap file amongst them all.
/ 96m (most I've seen used on fbsd is ~64m) /var 512m (4x+ for an email server, 2x for a webserver) /var/tmp 284m (soft-linked as /tmp) swap 1g (or 2x phys. memory) /usr 3g+ ( usually 4g unless space is tight) /home 1g (or softlink as /usr/home) /web 1g (if needed, or give to /usr)
If you have additional drives you can pad /var, /var/tmp and /usr or just mount it a /spare for future use.
You will be asked which distributions to install. Choose Developer or X-developer if you know you'll need X
net/cvsup-bin net/netcat net/trafshow security/chkrootkit security/logcheck security/portsentry (o)security/sudo (if the shoe fits) shells/bash2 shells/tcsh (o)sysutils/lsof (or just use sockstat from base)
vfs.vmiodirenable=1 hw.ata.wc=1 kern.ipc.shm_use_phys=1 kern.ipc.somaxconn=1024 net.inet.tcp.always_keepalive=1 net.inet.tcp.delayed_ack=0
Security, etc.
Check ntpd -v and make sure the version is 4.0.99k or higher
fix /etc/ntp.conf or just run ntp -bAp /var/run/ntpd.pid from rc.conf
xntpd_enable="YES" # Run ntpd Network Time Protocol (or NO). xntpd_program="ntpd" # path to ntpd, if you want a different one. xntpd_flags="-bAp /var/run/ntpd.pid" # Flags to ntpd (if enabled).
make sure inetd_enable="NO" or inetd_flags="-l -R 1024" if you must run it
Modify /etc/hosts.allow...
Disable ALL:ALL:ALLOW
then add/change these lines unless otherwise necessary
ALL : localhost 127.0.0.1 : allow sshd : 123.231.132.0/255.255.255.0 : ALLOW sshd : ALL : DENY sendmail : ALL : deny ftpd : ALL : deny portmap : ALL : deny
OpenSSH - turn off protocol 1 and make PermitRootLogin=no if possible
set UseLogin no
(in /etc/ssh/sshd_config usually)
Other things to set in /etc/rc.conf
syslogd_flags="-s -s" portmap_enable="NO" sendmail_flags="-q30m" (only need -bd if this is a mail server) named_enable="NO" (unless you need it) clear_tmp_enable="YES" (unless you have a good reason not to)
recompiling the kernel will usually be necessary at some point. Here are some options you will want to consider setting.
kern.ipc.somaxconn=1024
and kern.ipc.nmbclusters=4096
to /etc/sysctl.conf if the system will be a heavily-loaded network server. YMMV, go higher if you need to.[1]
[1] tuning (7) manpage
[2] Squid configuration tweaks
@ http://www.measurement-factory.com/results/public/cacheoff/N03/auto/b44/conf.html
[3] surlink.net FreeBSD Security Howto
[4] FreeBSD Handbook Chapter 6.9 Tuning Disks
1st Draft June 18, 2001 2nd Draft June 28, 2001 - fixing misinformation, adding packages selections 3rd Draft Aug 20, 2001 - modified hosts.allow, fixed typo 4th Draft Aug 22, 2001 - removed reference to bad option NO_LKM 5th Draft Aug 24, 2001 - added portmap to /etc/hosts.allow and sysctl.conf 6th Draft Oct 11, 2001 - added clear_tmp_enable="YES" to rc.conf section 7th Draft Apr 11, 2002 - adding hw.ata.wc variable 8th Draft May 15, 2002 - added supfile info 9th Draft Aug 11, 2003 - converted to HTML, published as article on website 10th Draft May 13, 2004 - added systl variables for tuning
If I was helpful, please let me know.
$Id: setup-freebsd.html,v 1.8 2005/11/12 16:36:00 mdf Exp $