FreeBSD installieren.

FreeBSD, Gentoo, openSUSE, CentOS, Ubuntu, Debian
User avatar
Proteus
Posts: 289
Joined: 2013-04-14 05:08
Location: Holzgerlingen
 

FreeBSD installieren.

Post by Proteus »

Hallo,

Joe User meinte das meine Vorgangsweise einen FreeBSD Server zu installieren Okay sei, diese man aber noch überarbeiten könnte. Was wäre von Vorteil und was von Nachteil, und was könnte man verbessern?

Hier noch mal meine Überarbeitete Liste:

Code: Select all

vi /etc/rc.conf 

fsck_y_enable="YES"                             # "NO"
firewall_enable="YES"                           # "NO"
firewall_script="/etc/ipfw.rules"               # "/etc/rc.firewall"
tcp_drop_synfin="YES"                           # "NO"
icmp_drop_redirect="YES"                        # "NO"
syslogd_flags="-ss"                             # "-s"
sshd_enable="YES"                               # "NO"
ntpdate_enable="YES"                            # "NO"
ntpdate_flags="-b -s -4"                        # "-b"
ntpdate_hosts="ptbtime2.ptb.de"                 # ""
keymap="german.iso"                             # "NO"
font8x16="ISO8859-1"                      # "NO"
font8x14="ISO8859-1"                      # "NO"
font8x8="ISO8859-1"                       # "NO"
sendmail_submit_enable="NO"                     # "YES"
sendmail_outbound_enable="NO"                   # "YES"
sendmail_msp_queue_enable="NO"                  # "YES"
cron_flags="$cron_flags -J 15"                  # ""
webmin_enable="YES"                             # "<not defined>"
nginx_enable="YES"                              # "<not defined>"
php_fpm_enable="YES"                            # "<not defined>"
mysql_enable="YES"                              # "<not defined>"
proftpd_enable="YES"                            # "<not defined>"
linux_enable="YES"

vi /etc/src.conf

WITH_BIND_SIGCHASE=YES
WITH_ICONV=YES

vi /etc/make.conf

THREAD=8
INSTALL_NODEBUG=YES
MASTER_SITE_BACKUP?= http://ftp4.de.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}

KERNCONF?=GENERIC
CPUTYPE?=opteron
CFLAGS= -O2 -fno-strict-aliasing -pipe
CXXFLAGS+= -fconserve-space
COPTFLAGS= -O -pipe
PRINTERDEVICE=ascii
SUP_UPDATE=
SUP=/usr/bin/csup
SUPFLAGS= -g -L 2
SUPHOST=cvsup.de.FreeBSD.org
SUPFILE=/usr/share/examples/cvsup/standard-supfile

JAVA_VERSION=1.7
JAVA_VENDOR=openjdk
WITHOUT_X11=YES
PERL_VERSION=5.16.2


echo '59  2  *  *  *  root  /usr/sbin/ntpdate -b -s -4 ptbtime2.ptb.de' >> /etc/crontab

vi /etc/profile

LANG=de_DE.ISO8859-1; export LANG
MM_CHARSET=ISO-8859-1; export MM_CHARSET

vi /etc/csh.login

setenv LANG de_DE.ISO8859-1
setenv MM_CHARSET ISO-8859-1

vi /etc/login.conf
 
default:\
	:passwd_format=blf:\
	:minpasswordlen=8:\
	:mixpasswordcase=true:\
	:idletime=30:\
	:umask=022:

unicode|Unicode Users Accounts:\
    :charset=UTF-8:\
    :lang=de_DE.ISO8859-1:
    :tc=default:

cap_mkdb /etc/login.conf
pw usermod root -L unicode

vi /etc/ttys

console none                            unknown off insecure

vi /etc/gettytab

P|Pc|Pc console:\
        :ht:np:sp#115200:\
        :cl=\E[H\E[2J:

Anschliessend muss die Datei in eine Systemdatenbank umgewandelt werden.

cap_mkdb /etc/login.conf

vi update.sh

#!/bin/sh
LOG_FILE="/var/log/freebsd-update.log"
echo "Starting updates: `date`" | tee -a ${LOG_FILE}
echo "***"
echo "*** Checking for FreeBSD patches..."
echo "***"
/usr/sbin/freebsd-update fetch | tee -a ${LOG_FILE}
/usr/sbin/freebsd-update install | tee -a ${LOG_FILE}
echo "***"
echo "*** Updating ports tree..."
echo "***"
/usr/sbin/portsnap fetch update | tee -a ${LOG_FILE}
echo "***"
echo "*** Updating ports extract..."
echo "***"
/usr/sbin/portsnap fetch extract | tee -a ${LOG_FILE}
echo "***"
echo "*** Looking for ports to update..."
echo "***"
/usr/local/sbin/portmaster -a --no-confirm | tee -a ${LOG_FILE}
echo "***"
echo "*** Checking installed ports for known security problems..."
echo "***"
/usr/local/sbin/portaudit -Fva | tee -a ${LOG_FILE}
echo "Finished updates: `date`" | tee -a ${LOG_FILE} 

chmod +x update.sh

Optional:

vi /etc/csh.cshrc

setenv LSCOLORS "Dxfxcxdxbxegedabagacad"
alias l         ls -lha
alias ls        ls -GF

vi /root/.cshrc

# $FreeBSD: release/9.1.0/etc/root/dot.cshrc 170088 2007-05-29 06:37:58Z dougb $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#

alias h         history 25
alias j         jobs -l
alias la        ls -a
alias lf        ls -FA
alias ll        ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set prompt = "[%B%n%b@%B%m%b:%B%~%b] %# "
        set filec
        set history = 1000
        set savehist = 1000
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                bindkey ^[[3~ delete-char
        endif
endif

su - master
umask 0077

vi .cshrc

# $FreeBSD: release/9.1.0/share/skel/dot.cshrc 170119 2007-05-29 22:07:57Z dougb $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#

alias h         history 25
alias j         jobs -l
alias la        ls -a
alias lf        ls -FA
alias ll        ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set prompt = "[%B%n%b@%B%m%b:%B%~%b] %# "
        set filec
        set history = 1000
        set savehist = 1000
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                bindkey ^[[3~ delete-char
        endif
endif

vi .vimrc

set background=dark
syntax on
set hlsearch
set nocompatible
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set showmatch
set ruler
set incsearch

cp .vimrc /home/master

vi /etc/ipfw.rules

IPF="ipfw -q add"
ipfw -q -f flush

#loopback
$IPF allow all from any to any via lo0
$IPF deny all from any to 127.0.0.0/8
$IPF deny all from 127.0.0.0/8 to any
$IPF deny tcp from any to any frag

# statefull
$IPF check-state
$IPF allow tcp from any to any established
$IPF allow all from any to any out keep-state
$IPF allow icmp from any to any

# Erlaube FTP
$IPF allow tcp from any to any 21 in setup
$IPF allow tcp from any 20 to any 1024-65535 in setup

# passive mode FTP erlauben - nicht empfohlen - wird ins log geschrieben
# um Missbrauch nachvollziehen zu koennen
$IPF allow log tcp from any 1024-65535 to any 1024-65535 in setup

# open port ssh (22), mail (25)
$IPF allow tcp from any to any 22 in
$IPF allow tcp from any to any 22 out
$IPF allow udp from any to any 53 in
$IPF allow tcp from any to any 53 in
$IPF allow udp from any to any 53 out
$IPF allow tcp from any to any 53 out

# http (80), dns (53) webmin (10000)
$IPF allow udp from any to any 80 in
$IPF allow tcp from any to any 80 in
$IPF allow udp from any to any 443 in
$IPF allow tcp from any to any 443 in
$IPF allow udp from any to any 445 in
$IPF allow tcp from any to any 445 in
$IPF allow udp from any to any 8080 in
$IPF allow tcp from any to any 8080 in
$IPF allow tcp from any to any 10000 in
$IPF allow tcp from any to any 10000 out

$IPF allow tcp from any to any 3306 in
$IPF allow tcp from any to any 3306 out

# Mail  110 143 25 465 585 993 995
$IPF allow tcp from any to any 25 in
$IPF allow tcp from any to any 25 out
$IPF allow tcp from any to any 110 in
$IPF allow tcp from any to any 110 out
$IPF allow tcp from any to any 143 in
$IPF allow tcp from any to any 143 out
$IPF allow tcp from any to any 465 in
$IPF allow tcp from any to any 465 out
$IPF allow tcp from any to any 585 in
$IPF allow tcp from any to any 585 out
$IPF allow tcp from any to any 993 in
$IPF allow tcp from any to any 993 out
$IPF allow tcp from any to any 995 in
$IPF allow tcp from any to any 995 out

#Default deny
$IPF deny all from any to any

echo 'firewall_enable="YES"' >> /etc/rc.conf 
echo 'firewall_script="/etc/ipfw.rules"' >> /etc/rc.conf

csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile && portsnap fetch && portsnap extract && portsnap update

cd /usr/ports/ports-mgmt/portupgrade && make install clean && portinstall portmaster && portinstall portaudit && portinstall -c sshguard-ipfw

cd /usr/ports/devel/subversion && make install  && cd /usr/src && fetch http://ftp4.de.freebsd.org/pub/FreeBSD/releases/amd64/9.1-RELEASE/src.txz && tar -C / -xvzf src.txz && rm src.txz

mkdir -p /usr/compat/linux/proc
ln -s /usr/compat /compat

vi /etc/fstab

linproc /compat/linux/proc linprocfs    rw      0       0

mount linproc

cd /usr/ports/distfiles

fetch ftp://ftp.tmn.ru/pub/FreeBSD/distfiles/mc-4.8.1.7.tar.xz

portinstall wget wput gzip zip htop mc vim

cd /usr/ports/ftp/proftpd && make install

cd /usr/ports/databases/mariadb55-server && make install
service mysql-server start
mysqladmin -u root password 4sbeUDMDSOjd

cd /usr/ports/www/nginx && make install
mkdir -p /var/log/nginx
vim /var/log/nginx/error.log

cd /usr/ports/lang/php5 && make install
cd /usr/ports/lang/php5-extensions && make install

mkdir -p /opt/conf
cd /opt/conf
fetch http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip ./GeoIP.dat.gz

cd /usr/obj
chflags -R noschg *
rm -rf *

grep IPFIREWALL /usr/src/sys/amd64/conf

cd /usr/src/sys/amd64/conf

cp GENERIC IPFWKERNEL

vim IPFWKERNEL

ihr fügt nun folgendes ein

machine   amd64
cpu       HAMMER
ident     GENERIC


options IPFIREWALL # required for IPFW
options IPFIREWALL_VERBOSE # optional; logging
options IPFIREWALL_VERBOSE_LIMIT=10 # optional; don't get too many log entries
options IPDIVERT # needed for natd

cd /usr/src

make buildkernel KERNCONF=IPFWKERNEL

make installkernel KERNCONF=IPFWKERNEL
LG
Proti

"Die Kamera wird bei hohen ISO Werten aber rauschen. Nichts ahnend hielt er sich die Kamera ans Ohr!"
User avatar
Joe User
Project Manager
Project Manager
Posts: 11189
Joined: 2003-02-27 01:00
Location: Hamburg
 

Re: FreeBSD installieren.

Post by Joe User »

Es hängt primär vom Einsatzzweck des Systems und selbstverständlich von Deinen Fähigkeiten als Admin ab.

Einige Teile aus http://www.rootservice.org/howtos/freeb ... stall.html hast Du ja bereits übernommen und die Deiner Meinung nach für Dein System unzutreffenden Teile nicht. Das ist völlig in Ordnung und gut so, denn meine Vorgehensweise passt schliesslich nicht überall.

Was ich Dir dringend anraten würde, wäre den ganzen Firewall-Quatsch wegzulassen und stattdessen die Dienste vernünftig zu konfigurieren. Firewalls gehören vor das zu schützende System und nicht darauf. Zudem macht Deine Firewall-Konfiguration nichts Anderes, als was der Kernel ohnehin schon völlig automatisch von allein macht. Sie kostet also derzeit nur unnötig Ressourcen.

Dann solltest Du auf automatische Updates jeglicher Art Abstand nehmen, denn die werden Dir Dein System garantiert irgendwann zerschiessen und Du wirst dann lange brauchen, um die Fehlerquelle (Autoupdates) zu finden. Für den Desktop zu Hause ist das OK, für einen Server ist das tödlich.

Als Nächstes würde ich auf das Einschränken auf ISO-8859-1 verzichten, denn UTF-8 beinhaltet ISO-8859-1 und noch viele andere mehr. Das erleichtert das Lesen einiger Docs, Configs und vor Allem Logfiles erheblich.

Wozu benötigst Du linprocfs und/oder die Linux-Compat?


Das wären meine zwei Cent
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
User avatar
Proteus
Posts: 289
Joined: 2013-04-14 05:08
Location: Holzgerlingen
 

Re: FreeBSD installieren.

Post by Proteus »

Joe User wrote:
Als Nächstes würde ich auf das Einschränken auf ISO-8859-1 verzichten, denn UTF-8 beinhaltet ISO-8859-1 und noch viele andere mehr. Das erleichtert das Lesen einiger Docs, Configs und vor Allem Logfiles erheblich.

Wozu benötigst Du linprocfs und/oder die Linux-Compat?


Das wären meine zwei Cent
Firewall kommt weg, das überzeugt mich. Denn auch Zuhause habe ich ja auch einen Router, der vor meinem PC steht, es ist allzu logisch. Ich werde wegen der Konformität die Charsets auf UTF-8 einstellen.

Linprofs benötige ich für Mindnight Commander und Htop, damit kann man dann doch mal schneller aus einem Tar etwas extrahieren und, mit Htop kann zumindest ich schneller Dienste abschießen.

Zum Updatescript, wenn ich in der make.conf einstelle das ein anderes Programm nicht angerührt werden soll, dann wird es ja nicht aktualisiert. Das Script das ich da gebastelt habe führe ich eigentlich nur einmal aus, und zwar nachdem ich alles installiert habe und dann eigentlich nicht mehr.


MfG

Proteus
Last edited by Proteus on 2013-05-06 19:12, edited 1 time in total.
LG
Proti

"Die Kamera wird bei hohen ISO Werten aber rauschen. Nichts ahnend hielt er sich die Kamera ans Ohr!"
User avatar
rudelgurke
Posts: 410
Joined: 2008-03-12 05:36
 

Re: FreeBSD installieren.

Post by rudelgurke »

Allgemeiner Hinweis zu FreeBSD - versuch's mal mit Ccache für die Ports - dass bringt mitunter etwas Geschwindigkeit beim Bauen von Ports.

Zum mc - linprocfs braucht der nicht, hatte ich noch nicht aktiv und bisher mit *.tar.* Archiven noch keine Probleme.

Schließlich:

make buildkernel KERNCONF=IPFWKERNEL
make installkernel KERNCONF=IPFWKERNEL

keine gute Idee. Damit überbügelst du den Default Kernel - wenn beim Build etwas schief geht, z. Bsp. Feature vergessen und die Kiste lädt nicht richtig hast du ein Problem - Default Kernel ist ja weg.

Besser:

make kernel KERNCONF=IPFWKERNEL KODIR=/boot/kernel_ipfw

nextboot -k kernel_ipfw

Schiebt der den eigenen Kernel in /boot/kernel_ipfw und bootet den beim nächsten Reboot (siehe /boot/nextboot.conf). Fährt die Kiste sauber hoch wieder:

nextboot -k kernel_ipfw

fährt die Kiste nicht sauber hoch, einen Reset triggern und der Default Kernel bootet wieder.

So kommt man ohne Umwege (iLO, Kvm etc.) erstmal wieder ran um zu sehen was schief ging.

Und wenn die schon unbedingt und ganz ganz sicher und überhaupt und sowieso und ganz dringend (wovon auch ich abraten würde) IPFW nehmen willst:

options IPFIREWALL_DEFAULT_TO_ACCEPT

setzt die Default Policy erstmal auf "ACCEPT". Falls deine Firewall Konfiguration ist irgendwelchen Gründen nicht lädt kommst du so noch ran und kannst dann die Default Policy wieder auf "REJECT" oder "DENY" setzen, sonst macht die Firewall was sie soll und sperrt jeden und alles aus - inkl. dir ;) und dass auch nach einem Reboot (außer Single User natürlich).

Dann in der rc.conf - die Fonts / Keymap kannst du weglassen wenn die ohnehin nur per ssh rangehst - da sagt der Client was Sache ist.

In der make.conf können die "SUP_*" Einträge raus. Die gehören noch zu cvsup / csup was es seit Februar glaube ich nicht mehr gibt.
Last edited by rudelgurke on 2013-06-30 15:33, edited 1 time in total.