Zum Inhalt springen

Gateway Installation: Unterschied zwischen den Versionen

Aus Opennet
Inhalt gelöscht Inhalt hinzugefügt
MathiasMahnke (Diskussion | Beiträge)
MathiasMahnke (Diskussion | Beiträge)
Merge mit Server Installation
 
(103 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
#REDIRECT [[Server Installation]]
Kurzer Leitfaden für das Aufsetzen neuer Vereinsgateways.

=== Hardware ===

* sinnvoll >500 Mhz CPU, >256 MB RAM
* mindestens 2 NICs
* ausreichend HD-Kapazität; ideal SCSI (z.B. U2W), alternativ IDE (mit z.B. RAID1)

=== Basisinstallation ===

* Booten, z.B. per CD oder PXE mit Knoppix
* Dateisystem vorbereiten:
** ''cfdisk /dev/<device>'', z.B. /dev/hda (IDE) oder /dev/sda (SCSI)
** primäre Partitionen: 32 MB boot (Typ 83 + bootable), 500 MB swap (Typ 82), Rest für / (Typ 83)
** boot mit EXT2: mkfs.ext2 /dev/<device>1
** swap mit SWAP: mkswap /dev/<device>2
** root mit XFS: mkfs.xfs /dev/<device>3
* Debian Stable (oder Testing) installieren
: a) Neuinstallation, vgl. [http://www.debian.de/releases/stable/i386/index.html.de Debian GNU/Linux-Installationsanleitung]
: c) per ''debootstap'' von Knoppix aus, vgl. [http://www.debian.de/releases/stable/i386/apcs04.html.de Debian GNU/Linux-Installationsanleitung - C.4]
: b) als Kopie von vorhandenem GW, z.B. [[GW250|izumi]]
::* Filesysteme auf izumi ggf. mounten, crontab Einträge ggf. deaktivieren (CPU-Last)
::* boot einbinden: mount /dev/<device>1 /mnt/
::* boot spiegeln: rsync -axz --numeric-ids root@izumi.on:/boot/ /mnt/
::* root einbinden: umount /mnt; mount /dev/<device>3 /mnt/
::* root spiegeln: rsync -axz --numeric-ids root@izumi.on:/ /mnt/
::* Minimale Device-Nodes anlegen (bei UDEV): MAKEDEV null console zero
* Bootloader installieren (''grub''):
** via chroot und grub-Skripte: (chroot...); grub-install --no-floppy /dev/<device>; update-grub
** oder manuell, dabei /boot/grub/menu.lst selbst anpassen/erstellen: grub --no-floppy (root (hd0,0) / setup (hd0) / quit)
* Kernel bauen / aktualisieren
** cd /usr/src/linux; make menuconfig; make; make install; make modules_install; update-grub
** ggf. local-version neu setzen

==== Hilfsmittel: chroot Umgebung ====
mount /dev/<device>3 /mnt
mount /dev/<device>1 /mnt/boot
mount -t proc proc /mnt/proc
mount --bind /dev /mnt/dev
chroot /mnt

==== Hilfsmittel: RAID mit mdadm ====

* spezieller Partitionstyp FD (Linux raid autodetect), mit cfdisk einstellen
* direkt: ''mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda3 /dev/hdc3''
* oder auch schrittweise:
** ''mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda3 missing''
** Daten in /hda3 einspielen
** ''mdadm --manage /dev/md0 --add /dev/hdc3''

=== Konfiguration ===

==== Allgemeines ====

* Hostname /etc/hostname + /etc/mailname
* Zeitzone /etc/timezone -> UTC
* Kernelmodule /etc/modules
* Dateisysteme /etc/fstab
/dev/<device>1 /boot ext2 noauto,noatime 1 1
/dev/<device>3 / xfs noatime 0 0
/dev/<device>2 none swap sw 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0

==== Netzwerk-Geräte ====

* Ethernet /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet static
address 192.168.0.X
netmask 255.255.0.0
network 192.168.0.0
broadcast 192.168.255.255
auto <peername>
iface <peername> inet ppp
provider <peername>
* PPP /etc/ppp/*
** /etc/ppp/pap-secrets -> "<account>" * "<password>"
** /etc/ppp/peers/<peername>, Defaults mit:
logfile /var/log/pppd/qsc-dsl.log
#defaultroute
hide-password
lcp-echo-interval 20
lcp-echo-failure 3
connect /bin/true
noauth
persist
mtu 1492
noaccomp
default-asyncmap
plugin rp-pppoe.so eth0
user "<account>"
:* ln -s /etc/ppp/peers/<peername> /etc/ppp/peers/provider
:* mkdir /var/log/pppd
:* /etc/ppp/ip-up.d
#!/bin/sh
# default routes
route add -net 0.0.0.0/1 gw $PPP_REMOTE
route add -net 128.0.0.0/1 gw $PPP_REMOTE
# uni rostock
route add -net 139.30.0.0/16 gw $PPP_REMOTE
# ipkg repositories
route add -host 195.56.146.238 gw $PPP_REMOTE
route add -host 212.91.225.42 gw $PPP_REMOTE
# wikipedia
route add -net 207.142.131.192/26 gw $PPP_REMOTE
route add -net 145.97.39.128/28 gw $PPP_REMOTE
route add -net 212.85.150.128/28 gw $PPP_REMOTE
# www.opennet-initiative.de
route add -host 212.105.204.29 gw $PPP_REMOTE
# rostock.de
route add -net 195.37.188.160/28 gw $PPP_REMOTE
:* /etc/ppp/ip-down.d/00routes - analog nur s/add/del

==== Routing ====

* OLSR /etc/olsrd.conf, Defaults mit:
UseHysteresis no
LinkQualityLevel 2
Interface "eth1" { <defaults> }
Hna4
{
# university rostock
139.30.0.0 255.255.0.0
# ipkg repositories
195.56.146.238 255.255.255.255
212.91.225.42 255.255.255.255
# wikipedia
207.142.131.192 255.255.255.192
145.97.39.128 255.255.255.240
212.85.150.128 255.255.255.240
# www.opennet-initiative.de
212.105.204.29 255.255.255.255
# www.rostock.de
195.37.188.160 255.255.255.240
}

* WAN-Routing /etc/network/ip-up.d/gatewaysetup.sh (Kopie besorgen)

==== SSH-Server ====

* ggf. neue Schlüssel erstellen in /etc/ssh/
** RSA-Host-Key per ''ssh-keygen -b 2048 -t rsa -f ssh_host_rsa_key''
** DSA-Host-Key per ''ssh-keygen -b 2048 -t dsa -f ssh_host_dsa_key''

==== VPN-Server ====

* OpenVPN:
** openvpn + openssl installieren
** zwei Instanzen aufbauen: <system> = opennet_gateways (VPN Backbone) | opennet_users (VPN Internet-Zugang für Nutzer)
** /etc/openvpn/<system>/openssl.conf anpassen (Kopie besorgen), Leserechte setzen (''chmod go-rwx <system>'')
** /etc/openvpn/opennet_<system>.conf anpassen (Kopie besorgen), key + cert anpassen
** Csr/Key erstellen: ''openssl req -days 3650 -nodes -new -keyout <hostname>.key -out <hostname>.csr -extensions server -config openssl.cnf'' (Common Name = <hostname>.on)
** Csr absenden und unterschreiben lassen, Crt einspielen, Leserechte setzen (''chmod go-rw *.key'')
** Diffie hellman PEM: ''openssl dhparam -out /etc/openvpn/dh2048.pem 2048''

* automatische ACL Aktualisierung:
** Nutzer openvpn-acl anlegen + absichern
** SSH Schlüsselpaar erzeugen: ''su openvpn-acl; cd .ssh/; ssh-keygen -t rsa''
** SSH Public Key (id_rsa.pub) in opennetca@ratte:.ssh/authorized_keys hinzufügen
** cronttab für openvpn-acl mit "*/10 * * * * rsync -rt --delete --safe-links opennetca@139.30.3.52:'opennet_users opennet_users_disabled' /etc/openvpn/acl"

==== Nameserver ====

* zuerst chroot-bind9 installieren und einrichten
* rndc absichern per ''rndc-conf -a'' (Key ins chroot kopieren)
* im chroot /etc/bind/named.conf.options:
options {
directory "/var/cache/bind";
forward first;
forwarders {
<isp-dns1>;
<isp-dns2>;
192.168.0.254;
};
auth-nxdomain no; # conform to RFC1035
listen-on {
127.0.0.1;
<gateway-ip>
};
# ignoriert unterstrich in Domainnamen vom ON
check-names slave ignore;
};
* im chroot /etc/bind/named.conf.local:
// on - forward (includes vpn)
zone "on." {
type slave;
file "db.on";
masters {192.168.0.254;};
};
//on - reverse
zone "168.192.in-addr.arpa" {
type slave;
file "db.192.168";
masters {192.168.0.254;};
};
//on-vpn - reverse
zone "1.10.in-addr.arpa" {
type slave;
file "db.10.1";
masters {192.168.0.254;};
};
* lokale Namensauflösung /etc/resolv.conf:
search on
nameserver 127.0.0.1
* Nameserver starten: ''/etc/init.d/bind9 start''
* Funktion prüfen: ''ps aux|grep bind'' und ''rndc status''
* Fehlermeldungen suchen: ''grep named /var/log/daemon.log|tail -20''
* Zonen-Transfer manuell durchführen: ''rndc retransfer on''

==== Webserver ====

* apache2 installieren
** in /etc/apache2/ports.conf eintragen: Listen 80
** Default-Site deaktivieren: #RedirectMatch ^/$ /apache2-default/
** Default-Site unter /var/www/apache2-default ggf. löschen
** CGI-BIN deaktivieren: /etc/apache2/mods-enabled/cgi.load löschen; ggf. in sites-enabled/ den cgi-bin Eintrag löschen

* OpenVPN-Status-Skript anpassen unter /root/tasks/openvpn-users-status.py: host = '<hostname>.on'

[[Kategorie:Konfiguration]]
[[Kategorie:Opennet Projekte]]

==== NTP-Server ====

* ntpdate und ntpd installieren
* beide beim Systemstart starten lassen (zur Sicherheit zuerst ntpdate, dann ntpd)
:* ntpd hat Probleme mit dynamisch wechselnen IP Adressen. Im Daemon Log finden sich Einträge wie ''ntpd[2466]: sendto(83.67.66.148): Invalid argument''. Ich würde hier vorschlagen ntpdate in crontab einzutragen.
:* ntpdate als cronjob hat wirklich unschöne Resultate. Ich bin dafür den ntpd ohne restart davon zu überzeugen, die neue global ip zu nutzen. Zur Nutzung des management-sockets sind zunächst keys zu erstellen:
sudo su
mkdir -p /etc/ntp
chmod go-rx /etc/ntp
cd /etc/ntp
ntp-keygen
chmod go-rxw *
chmod go+rx /etc/ntp
ln -sf ntpkey_MD5key* keys
In /etc/ntp.conf sind dann folgende Einträge erforderlich:
keys /etc/ntp/keys
keysdir /etc/ntp/
trustedkey 10
requestkey 10
restrict 127.0.0.1
Folgendes script als /usr/local/bin/ntpdrehash ablegen:
<nowiki>
#!/bin/sh
#
# reconfigNtpd, written by Jan Ceuleers, March 2003, revised October 2003
#
# Purpose: ntpd running on a machine that has intermittent connectivity to
# the Internet, and that does not have a static public IP address,
# loses its associations with public NTP servers, even after the
# connection to the Internet has been restored.
# Restarting the ntpd daemon is a possibility, but the downside
# is that this causes time not to be served to local clients until
# ntpd has regained synchronisation.
# A better way is to configure at least one local clock (the local
# clock 127.127.1.0 at high stratum and/or a refclock), to cover
# for the periods when there is no Internet connectivity, and to
# use this script to unconfig/add{server,peer} all public time
# servers at runtime (i.e. without restarting the daemon)
#
# Usage: reconfigNtpd | ntpdc
#
# Bugs: * This script only generates unconfig/addpeer and unconfig/addserver
# pairs. Any relevant fudge statements or iburst options etc. are
# ignored.
#
# * Location of keys file is hard-coded rather than being derived from
# ntp.conf
#
###
#
# Get keyid and password from /etc/ntp/keys
#
###
set -- $(grep "^[[:digit:]]" < /etc/ntp/keys)
echo keyid $1
echo passwd $3
###
#
# Derive unconfig commands from ntpdc output
#
###
ntpdc -n -p | awk '!/==/ && !/^ / { if (substr($1,2) !~ /^127.127./)
print "unconfig " substr($1,2) }'
###
#
# Derive addserver commands from /etc/ntp.conf
#
###
#awk '/^server[[:blank:]]/ { if ($2 !~ /^127.127./) print "addserver " $2
#}' /etc/ntp.conf
awk '/^server/ { if ($2 !~ /^127.127./) print "addserver " $2
}' /etc/ntp.conf
###
#
# Derive addpeer commands from /etc/ntp.conf
#
###
awk '/^peer[[:blank:]]/ { print "addpeer " $2 }' /etc/ntp.conf
echo quit
</nowiki>
Und schliesslich /etc/ppp/ip-up.d/70ntpdrehash anlegen:
#!/bin/sh
/usr/local/bin/ntpdrehash | ntpdc &

=== Opennet Tools ===

==== Traffic Graphen ====

siehe [[Gateway_Installation/Teucrium Setup]]

==== Traffic Shaping ====

siehe [[Gateway_Installation/Traffic Shaping]]

==== MTA ====

Es ist sinnvoll einen MTA zu konfigurieren damit Statusmeldungen per Mail an ein administratives Postfach geschickt werden können. Normalerweise würde es reichen dafür das Debian Paket ''nullmailer'' zu installieren. Bei Gateways mit dynamischer IP benötigt man allerdings SMTP Auth zum versenden der Mails bzw. zur Authentifizierung beim Relayhost. Deswegen schlage ich vor hier Postfix als schlanken und einfach zu konfigurierenden MTA zu verwenden.

===== Benötigte Pakete =====

postfix libsasl2-modules postfix-tls

===== Minimalkonfiguration =====

Konfiguriert wird Postfix über ''/etc/postfix/main.cf''.

<pre>
# hostname/domain definition
myhostname = hikaru.opennet-initiative.de

# myorigin wird an lokal generierte mails angehaengt
myorigin = $mydomain

# Aliase für lokale User
alias_maps = hash:/etc/aliases

# Postfix ist nur fuer localhost zuständig
mynetworks = 127.0.0.0/8

# alle Mails sollen über unseren Relayhost gesendet werden
# (mit Dynamischen IP's und ohne PTR-Record sollte man lieber keine Mails versenden)
relayhost = relayhost.opennet-initiative.de

# Zum authentifizieren beim Relayhost benötigen wir SMTP Auth
# ''/etc/postfix/sasl_passwd'' hat folgendes Format
# hostname user:pass
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options =
</pre>

Die Datei ''/etc/postfix/sasl/passwd'' anlegen und aktuellen Inhalt besorgen.

Zudem ist noch eine kleine Änderung an ''/etc/postfix/master.cf'' notwendig. Über diese Datei wird gesteuert welche vom Postfix Masterprozess gestartet werden. Damit legen wir fest das Postfix nur an lo lauscht.

sed -i -e "s/\(^smtp.*smtpd.*$\)/127.0.0.1:\1/" master.cf

===== häufig benötigte Kommandos =====

* Konfiguraion neuladen: postfix reload
* Default Konfiguration ausgeben: postconf -d
* Nach Änderungen an /etc/aliases: postalias /etc/aliases
* Warteschlange prüfen: postqueue -p

Aktuelle Version vom 9. Oktober 2011, 17:47 Uhr

Weiterleitung nach: