StuRa:Server/FreeBSD
Dokumentation für den FreeBSD-Server
Jails
Jails dienen der Virtualisierung von Betriebssysteminstanzen. Näheres dazu im FreeBSD Handbuch Kapitel 15 - Jails.
Anlegen eines Jails
cd /usr/src- evtl. erst Sourcen installieren: sysinstall-> configure -> distributions
- evtl.
# make buildworld - Jails liegen unter /home/jails/$JAILNAME
- System für jail bauen:
# make installworld DESTDIR=/home/jails/$JAILNAME# make distribution DESTDIR=/home/jails/$JAILNAME
- device nodes ins jail packen
# mount -t devfs devfs /home/jails/$JAILNAME/dev
- resolv.conf kopieren:
cp host /etc/resolv.conf to /home/jails/$JAILNAME/etc/resolv.conf - rc.conf editieren:
- jail_enable="YES"
- jail_list="$JAILNAME"
- ifconfig_bce0_alias0="$JAIL_IP netmask 255.255.255.0"
- jail_$JAILNAME_rootdir="/usr/home/jails/$JAILNAME"
- jail_$JAILNAME_hostname="$JAILNAME.stura.htw-dresden.de"
- jail_$JAILNAME_ip="$JAIL_IP"
- jail_$JAILNAME_devfs_enable="YES"
- jail_$JAILNAME_devfs_ruleset="devfs_rules_jail"
- jail starten:
/etc/rc.d/jail start - Prozess im jail starten:
jexec $JAIL_ID tcsh- $JAIL_ID aus
jlsermittelbar - portscollection etc. installieren ...
portsnap fetch && portsnap extract && portsnap update- evtl. ssh anschalten (in rc.conf):
sshd_enable="YES"
- $JAIL_ID aus
Löschen eines Jails
- ins jailroot wechseln (/home/jails/$JAILNAME)
chflags -R noschg *rm -rf *cd .. && rm -r $JAILNAME
Tricks, Probleme etc.
- sich evtl. ezjail mal anschauen (war damals kaputt)
- ping aus jails heraus erlauben
- host: allow_raw_socket=1 via
#sysctl security.jail.allow_raw_sockets=1- bzw. in /etc/sysctl.conf setzen
- Quelle
- host: allow_raw_socket=1 via
- ssh:
- etc/ssh/sshd_config:
ListenAddress 0.0.0.0
- etc/ssh/sshd_config:
ssh
- openssh
- ssh auf anderen port legen
- Vorschläge für /etc/ssh/sshd_config:
VersionAddendumPort $SSH_PORTNUMMERListenAddress $JAIL_IPProtocol 2SyslogFacility AUTHLogLevel INFOLoginGraceTime 1mPermitRootLogin noStrictModes yesMaxAuthTries 4MaxSessions 5AllowUsers $DER_COOLE_LEUTE_CLUBPermitEmptyPasswords noX11Forwarding noBanner none
- immer schön manpage lesen und mit dem Feinkamm durchgehen
- keys + passwörter zur Authentifizierung
- in jails:
ListenAddress 0.0.0.0
MTA: postfix
- in the email jail
# cd /usr/ports/mail/postfix# make install clean- postfix added to group mail -> y
- Would you like to activate Postfix in /etc/mail/mailer.conf -> y
- Einstellungen (Auszug + aliases)
- edit /usr/local/etc/postfix/main.cf:
local_recipient_maps = $alias_mapsunknown_local_recipient_reject_code = 550mynetworks = 127.0.0.0/8myhostname = mail.stura.htw-dresden.demydomain = stura.htw-dresden.demyorigin = $mydomainmydestination = $myhostname, localhost.$mydomain, localhost, $mydomaininet_interfaces = allalias_maps = hash:/etc/aliasesalias_database = hash:/etc/aliaseshome_mailbox = Maildir/mail_spool_directory = /var/spool/mailrelay_domains = stura.htw-dresden.desmtpd_recipient_restrictions = reject_invalid_hostname,reject_unknown_recipient_domain,reject_unauth_destination,reject_rbl_client sbl.spamhaus.org,permitsmtpd_helo_restrictions = reject_invalid_helo_hostname,reject_non_fqdn_helo_hostname,reject_unknown_helo_hostnamesmtpd_client_restrictions = reject_rbl_client dnsbl.sorbs.net
MDA: dovecot
- optionen: kqueue, ssl, managesieve, mysql
#echo 'dovecot_enable="YES"' >> /etc/rc.conf#cp /usr/local/share/examples/dovecot/dovecot.conf /usr/local/etc/dovecot.conf#cp /usr/local/share/examples/dovecot/dovecot-sql.conf /usr/local/etc/dovecot-sql.conf- in /usr/local/etc/dovecot.conf: (vorerst zum testen)
protocols = imap pop3disable_plaintext_auth = nossl = nomail_location = mbox:~/mail/:INBOX=/var/mail/%umail_privileged_group = mailprotocol imap {imap_client_workarounds = delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep}
- Krypto drankleben (imap -> imaps, pop3 -> pop3s)
Tricks etc.
- alias-Adressen anlegen
- edit: /usr/local/etc/postfix/main.cf:
alias_maps = hash:/etc/aliases, hash:/etc/aliases.sturaalias_database = hash:/etc/aliases,hash:/etc/aliases.stura- edit /etc/aliases.stura:
newaliasespostfix reload# usr/local/etc/rc.d/postfix restart
- SMTP testen:
nc $JAIL_IP 25HELO microsoft.comMAIL FROM:<bill@microsoft.com>RCPT TO:<test@stura.htw-dresden.de>DATAFrom: <bill@microsoft.com>To: <stest@stura.htw-dresden.de>Subject: huidas hätte nicht passieren sollen.QUIT
Plone
- JoSch damals gebaut, zwischenzeitlich grundsaniert
- Apache installiert
- apache 22 optionen:
- mod_ssl
- mod_rewrite
- mod_deflate
- ipv6
- apr ohne berkeley db und gnu db
- http://plone.org/documentation/kb/freebsdploneapache/preparefreebsd
- http://plone.org/documentation/kb/freebsdploneapache/preparefreebsd
DNS
- genutzt werden DNS Server des FoeBuD und des CCC
- zusätzlich (für OpenNIC)
- DE,NRW 217.79.186.148 ns1.nrw.de.dns.opennic.glue Günter Grodotzki yes (no logs kept)
- NZ 27.110.120.30 ns1.nz.dns.opennic.glue Dean Gardiner yes (24 hrs)
Tricks etc.
- ports aktuell halten:
- portsnap /var/db/portsnap/INDEX
- edit /etc/crontab:
0 13 * * * root portsnap -I cron update && pkg_version -vIL=
- tägliches Audit der (installierten) Ports:
- portaudit /var/db/portaudit/auditfile.tbz
- edit /etc/crontab:
0 14 * * * root portaudit -Fda