FreeBSD 9 System aufsetzen

Nach dem die Installation von FreeBSD 9 erfolgreich abgeschlossen wurde, können folgende Schritte sinnvoll sein.

Diese Schritte stellen meine persönliche Vorgehensweise dar und sind bestimmt nicht die ultimativ richtige Vorlage für jede Installation.

1. Ports aktualisieren

  1. 
  2. portsnap fetch extract

2. Make Konfiguration

Damit die Applikationen von Anfang etwas schneller installiert werden, gehört für mich in die Datei /etc/make.conf

  1. 
  2. THREAD=4
  3. INSTALL_NODEBUG=YES
  4. MASTER_SITE_BACKUP?= ftp://ftp2.de.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
  5. MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}

3. Im Screen arbeiten

Die Applikation ist schnell installiert und schützt vor unangenehmen Abbrüchen: Das Tool screen

  1. 
  2. cd /usr/ports/sysutils/screen && make install clean && rehash && screen

Kleine Hilfe:

  • Strg-ad Screen in den Hintergrund, alle Prozesse im Screen laufen weiter. Dieser Screen lässt sich mit screen -r wieder herstellen.
  • Strg-d Screen schließen; dies schließt auch alle Prozesse im Screen.
  • Strg-ac Neuen Screen im Screen öffnen, dieser neue Screen lässt sich auch mit Strg-d wieder schließen
  • Strg-aa Zum vorherigen Screen umschalten

Natürlich gibt es noch mehr wissenswertes über Screen.

4. Mit den Ports arbeiten

Es gibt zahlreiche Werkzeuge Ports. In der Regel wird portmaster bevorzugt. Meine Wahl fällt auf portupgrade:

  1. 
  2. cd /usr/ports/ports-mgmt/portupgrade && make config-conditional install clean && rehash

Das dauert dann eine Weile, schließlich werden jetzt Perl, Ruby & Co gebaut ....

4. NTP

NTP konfigurieren und starten.

Monitoring

SmartMonTools

Installieren

  1. 
  2. portinstall smartmontools

Konfigurieren der zwei SATA-Platten

Editieren der Datei /usr/local/etc/smartd.conf

  1. 
  2. # -a alle SMART-Werte beobachten
  3. # -o on aktiviert regelmaessiges OFFLINE-Testen
  4. # -S on aktiviert autosave
  5. # -H Health-Status ausgeben
  6. /dev/ada0 -a -o on -S on -H
  7. /dev/ada1 -a -o on -S on -H

Und den smartd automatisch starten:

  1. 
  2. echo 'smartd_enable="YES"' >> /etc/rc.conf && /usr/local/etc/rc.d/smartd start

Munin

  1. 
  2. portinstall -c munin-node
  3. portinstall -c munin-common munin-master

Monit

  1. 
  2. portinstall -c monit

Sicherheit

Ist SSH weltweit offen, sollte mindestens sshguard installiert werden. Dieser benötigt die FreeBSD eigene Firewall ipfw, doch der Reihe nach:

1. Installation

  1. 
  2. portinstall -c sshguard-ipfw

Firewall

Minimale Firewall-Konfiguration in der Datei /etc/ipfw.conf:

  1. 
  2. # Erlaube Loopback
  3. add 1000 allow ip from any to any via lo0
  4. 
  5. # Erlaube Pakete von bestehenden Verbindungen
  6. add 1010 allow tcp from any to any established
  7. add 1015 allow all from any to any out keep-state
  8. add 1020 allow all from any to any frag
  9. 
  10. # Erlaube notwendigen ICMP Traffic (etwa Ping)
  11. add 1030 allow icmp from any to any icmptype 0,3,4,11,12
  12. 
  13. # Erlaube Network Time (NTP)
  14. add 2010 allow udp from any 123 to any 123 
  15. 
  16. # Erlaube DNS
  17. add 2050 allow udp from any to any 53 out
  18. add 2051 allow udp from any 53 to any in
  19. 
  20. # Verbiete FTP
  21. add 3110 deny tcp from any to any 21 in
  22. add 3120 deny tcp from any to any 21 out
  23. 
  24. # Erlaube SSH
  25. add 56000 allow tcp from any to any 22 in setup
  26. 
  27. # Erlaube alles andere
  28. add 56010 allow ip from any to any

Dann die rc.conf ergänzen:

  1. 
  2. echo 'firewall_enable="YES"' >> /etc/rc.conf
  3. echo 'firewall_type="/etc/ipfw.conf"' >> /etc/rc.conf
  4. /etc/rc.d/ipfw start

Läuft die Firewall, muss nun noch der syslogd konfiguriert und neu gestartet werden. Dazu in der Datei /etc/syslog.conf das Kommentarzeichen zu Beginn entfernen

  1. 
  2. auth.info;authpriv.info |exec /usr/local/sbin/sshguard

Und dann neu starten:

  1. 
  2. /etc/rc.d/syslogd restart

Applikationen

Je nach Einsatz werden unterschiedliche Applikationen benötigt. Die Installation erfolgt für mich via portinstall mit den Optionen c (Konfiguration und P Folgende gehören für mich zu jeder FreeBSD-Installation:

  • portinstall -cP portaudit && rehash && portaudit -dFa
  • portinstall -cP bash
  • portinstall -Pc phpMyAdmin
    (Installiert Apache 2.2, PHP 5.3 inklusive Erweiterungen und MySQL 5.5 gleich mit)
  • portinstall -c anacron (für Rechner die nicht 24/7 laufen)
    1. 
    2. Configuration hints:
    3. - Edit /usr/local/etc/anacrontab
    4. - Deactivate the 'periodic' commands in /etc/crontab
    5. - Add a call to anacron to /etc/crontab, like
    6. 0 0 * * * root /usr/local/sbin/anacron
    7. - Add anacron_enable="YES" to /etc/rc.conf
    8. - Read anacron(8) and anacrontab(5)