Schlagwort-Archive: linux

Raspberry Pi: Selfhosted cloud with ownCloud 6 beta

Quick writeup on how to install the new owncloud 6 beta on your raspberry Pi.

Disclaimer: If you want something superfast, leave this site now. If you’re looking for a really cheap way to get your own cloud (No NSA. So yay!) and give some use to your raspberry pi which is sitting on the shelf since months, here you go. Just don’t expect a 1 to 1 dropbox/drive/$whatever clone.

Prequirements: Working Raspberry Pi with Raspbian (path etc. may vary on other distributions) and a running webserver with php and ssl.

Installation on the Pi
Download the package from here, extract it, move it to the right location and set the correct user rights:

pi@raspberrypi ~ $ wget http://download.owncloud.org/community/testing/owncloud-6.0.0beta1.zip
pi@raspberrypi ~ $ unzip owncloud-6.0.0beta1.zip
pi@raspberrypi ~ $ sudo mv owncloud /var/www/
pi@raspberrypi ~ $ sudo chown -R www-data:www-data /var/www/owncloud
pi@raspberrypi ~ $ cd /var/www/owncloud/

We need to change a few settings in the php config.

pi@raspberrypi /var/www/owncloud $ sudo vi /etc/php5/fpm/php.ini

Replace

upload_max_filesize = 2M
post_max_size = 8M

with

upload_max_filesize = 1024M
post_max_size = 1024M

and add some lines to the end of the file (we will install apc later):

upload_tmp_dir = /srv/www/owncloud/data/temp
extension = apc.so
apc.enabled = 1
apc.include_once_override = 0
apc.shm_size = 256

Create the directory for uploads

pi@raspberrypi /var/www/owncloud $ sudo mkdir -p data/temp
pi@raspberrypi /var/www/owncloud $ sudo chown -R www-data:www-data data

After editing your webserver config according to the documentation, visit http://localhost/owncloud or http://raspberryip/owncloud and check for error messages. In my case, I got two:

1. PHP module GD is not installed. Please ask your server administrator to install the module.

So I needed to install this:

pi@raspberrypi /var/www/owncloud $ sudo aptitude install php5-gd

And

2. No database drivers (sqlite, mysql, or postgresql) installed.

Of course. After some searching and reading the official documentation about the database configuration, I decided to use MySQL as backend. Mainly because there will be at least two persons using the system. So I installed the mysql-server and php5-mysql package.

pi@raspberrypi /var/www/owncloud $sudo aptitude install mysql-server php5-mysql

After settings the root password, connect to your mysql server. Create a user for owncloud and a database.

pi@raspberrypi /var/www/owncloud $ mysql -u root -h localhost -p
CREATE USER ‚owncloud’@’localhost‘ IDENTIFIED BY ‚password‘;
CREATE DATABASE IF NOT EXISTS owncloud;
GRANT ALL PRIVILEGES ON owncloud.* TO ‚owncloud’@’localhost‘ IDENTIFIED BY ‚password‘;
QUIT

Return to http://localhost/owncloud or http://raspberryip/owncloud and complete the setup process.

Some tips to improve performance:
There are a few guides and tips on the net on how to improve performance of owncloud on your pi. Here are some of them.

1. Install the PHP Accelerator (see modified php.ini at the top)

pi@raspberrypi /var/www/owncloud $ sudo aptitude install php-apc

2. Use a cronjob to update the database and fasten up the webinterface. Open the crontab for the webserver user:

pi@raspberrypi /var/www/owncloud $ sudo crontab -u www-data -e

For updates every 15 minutes add:

*/15 * * * * php -f /var/www/owncloud/cron.php

On the webinterface go to Administration -> Cron and change the setting to Cron.

3. Disable unused apps. Disable all apps you don’t need.

 

Installation of the owncloud ubuntu client

pat@think:~$ wget http://download.opensuse.org/repositories/isv:ownCloud:devel/xUbuntu_13.10/Release.key
pat@think:~$ sudo apt-key add Release.key
pat@think:~$ echo ‚deb http://download.opensuse.org/repositories/isv:ownCloud:devel/xUbuntu_12.04/ /‘ >> sudo tee /etc/apt/sources.list.d/owncloud-client.list
pat@think:~$ sudo aptitude update
pat@think:~$ sudo aptitude install owncloud-client

Sources: http://doc.owncloud.org/server/5.0/admin_manual/installation/installation_others.html#nginx-configuration http://doc.owncloud.org/server/5.0/admin_manual/configuration/background_jobs.html#cron-jobs http://doc.owncloud.org/server/5.0/admin_manual/configuration/configuration_database.html http://jankarres.de/2013/10/raspberry-pi-owncloud-server-installieren/ (german) http://cloudlog.de/owncloud-langsam-diese-tipps-machen-owncloud-schneller/ (german)

Raspberry Pi: nginx Webserver with PHP and SSL

Installing the needed packages:

pi@raspberrypi ~ $ sudo aptitude install nginx php5-fpm php5-cgi php5-cli php5-common

There are different version of nginx available. For a comparison take a look at the debian wiki: https://wiki.debian.org/Nginx

Create the needed directory and php test file for later:

pi@raspberrypi ~ $ sudo mkdir /var/www
pi@raspberrypi ~ $ echo „<?php phpinfo(); ?>“ | sudo  tee /var/www/index.php
pi@raspberrypi ~ $ sudo chown -R www-data:www-data /var/www

Setting up SSL:

pi@raspberrypi ~ $ sudo mkdir /etc/nginx/conf.d/ssl && cd /etc/nginx/conf.d/ssl
pi@raspberrypi /etc/nginx/conf.d/ssl $ sudo openssl genrsa -out server.key 2048
pi@raspberrypi /etc/nginx/conf.d/ssl $ sudo openssl req -new -key server.key -out server.csr
pi@raspberrypi /etc/nginx/conf.d/ssl $ sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

And finally configure nginx:

pi@raspberrypi /etc/nginx/conf.d/ssl $ sudo vi /etc/nginx/sites-available/default

server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name localhost;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
try_files $uri $uri/ /index.html;
}
}

# HTTPS server
#
server {
listen 443;
server_name localhost;
root /var/www;
autoindex on;
index index.php index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/conf.d/ssl/server.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/server.key;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
try_files $uri $uri/ /index.html;
}
}

Visit http://localhost or https://localhost and you should see your php configuration.

Samba Freigaben mit Leerzeichen mounten

Weil ich es ständig nachschauen muss und dem ein oder anderen evtl. hilft:

Leerzeichen im Freigabenamen werden in der /etc/fstab mit \040 dargestellt. Ein Eintrag sieht dann zum Beispiel so aus:

//IP/Freigegebener\040Ordner /mnt/ziel cifs noauto,users,uid=1000, gid=100,file_mode=0755,dir_mode=0750,iocharset=utf8,credentials=~/.smbcredentials 0 0

(Zeilenumbruch nur zur Formatierung)

EDIT: Einige Feedreader haben wohl ein Problem mit der Zeichenkette. \ 0 4 0 (Backslash – Null – Vier – Null)

Raspberry Pi: Mount and unmount truecrypt on startup and shutdown

My Raspberry Pi functions as a lokal NAS and data haven for backing up remote servers and all my clients. The data is stored in a truecrypt container on an external usb harddrive. The drive is mounted on bootup, as well as the decrypted container. If you follow my notes, please be aware that the password to unlock the files is stored in cleartext in the automount script and could show up when running e.g. ps. So maybe this isn’t the right solution when you grant access to your Pi to other people.

 

Create the two directories to mount the external harddrive and the truecrypt container.

sudo mkdir /mnt/{usb,truecrypt}

If you use NTFS as a filesystem on your external drive, install the ntfs-3g package and try mounting the it manually first:

pi@raspberrypi ~ $ sudo aptitude install ntfs-3g
pi@raspberrypi ~ $ mount -t ntfs-3g /dev/sda1 /mnt/usb

When everything works, add the permanent mount entry to your /etc/fstab:

/dev/sda1 /mnt/usb ntfs-3g defaults 0 0

To automount the truecrypt container on startup, install truecrypt like explained here and create the two init scripts for mounting and unmounting the container.

/etc/init.d/tc_mount

#!/bin/bash
### BEGIN INIT INFO
# Provides:          tc_mount
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2
# Default-Stop:
# Short-Description: tc_mount
# Description:      Mount the truecrypt container
### END INIT INFO
echo „Mounting truecrypt container“
/usr/local/bin/truecrypt -t -k „“ –protect-hidden=no –mount /mnt/usb/crypt /mnt/truecrypt/ -v -m=nokernelcrypto -p ‚YOURPASSWORD‘
exit 0

/etc/init.d/tc_unmount

#!/bin/bash
### BEGIN INIT INFO
# Provides:          tc_unmount
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:
# Default-Stop:      0 1 6
# Short-Description: tc_unmount
# Description:       Unmount the truecrypt container
### END INIT INFO
echo „Unmounting truecrypt containers“
/usr/local/bin/truecrypt -d
exit 0

And add them to the correct runlevels:

pi@raspberrypi ~ $ sudo update-rc.d tc_mount start 02 2 .
pi@raspberrypi ~ $ sudo update-rc.d tc_unmount stop 02 0 1 6 .

 

Sources:

http://debianforum.de/forum/viewtopic.php?f=34&t=123447

https://www.linuxquestions.org/questions/debian-26/run-this-command-when-the-computer-shutdown-or-reboot-683851/

Raspberry Pi: Truecrypt on Raspbian

Quick howto on how to install truecrypt on the rapberry pi.

Get the source for Mac OS X/Linux from http://www.truecrypt.org/downloads2 (Update: https://www.grc.com/misc/truecrypt/truecrypt.htm) and copy the file to the pi:

pat@earth Downloads]$ scp TrueCrypt 7.1a Source.tar.gz pi@pi:/home/pi/

Connect to the pi and extract the archive:

pi@raspberrypi ~ $ tar xfv TrueCrypt 7.1a Source.tar.gz

Even without a GUI, you’ll need WxWidget. Download and extract:

pi@raspberrypi ~ $ wget http://prdownloads.sourceforge.net/wxwindows/wxWidgets-2.8.12.tar.gz
pi@raspberrypi ~ $ tar xfv wxWidgets-2.8.12.tar.gz

Install the fuse library:

pi@raspberrypi ~ $ sudo aptitude install libfuse-dev

Create a folder and download some needed header files:

pi@raspberrypi ~ $ mkdir ~/truecrypt-7.1a-source/pkcs
pi@raspberrypi ~ $ wget ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20/*.h -P truecrypt-7.1a-source/pkcs/

Change to the truecrypt directory and compile WxWidgets (takes about 20 minutes):

pi@raspberrypi ~ $ cd truecrypt-7.1a-source/
pi@raspberrypi ~/truecrypt-7.1a-source $ export PKCS11_INC=/home/pi/truecrypt-7.1a-source/pkcs/
pi@raspberrypi ~/truecrypt-7.1a-source $ make NOGUI=1 WX_ROOT=/home/pi/wxWidgets-2.8.12 wxbuild

Now compile truecrypt (~ 40 minutes):

pi@raspberrypi ~/truecrypt-7.1a-source $ make NOGUI=1 WXSTATIC=1

Copy the binary into the bin directory:

pi@raspberrypi ~/truecrypt-7.1a-source $ sudo cp Main/truecrypt /usr/local/bin/

Mount your container:

pi@raspberrypi ~/truecrypt-7.1a-source $ truecrypt -t -k „“ –protect-hidden=no –mount /mnt/usb/crypt /mnt/truecrypt/ -m=nokernelcrypto

Cleanup:

pi@raspberrypi ~/truecrypt-7.1a-source $ cd ~
pi@raspberrypi ~ $ rm -r truecrypt-7.1a-source TrueCrypt 7.1a Source.tar.gz wxWidgets-2.8.12*

Edit: I uploaded the binary. If you don’t want to compile truecrypt yourself, feel free to use this one.

Edit 2: If you want to automatically mount the truecrypt container on startup and unmount on shutdown, take a look at this howto.

Ubuntu Server 11.04 LTS, snd_intel, Realtek ALC892 und ALSA

Vor ein paar Tagen habe ich Mainboard und CPU beim media pc getauscht. Das neue Board ist ein DH67BL von Intel und hat einen anderen Soundprozessor verbaut. Leider wird dieser vom aktuellen Paket im Repo nicht unterstützt.

Erkannt wird er als:

cat /proc/asound/card0/codec#0  | grep Codec
Codec: Realtek ALC892

 

Hier bzw. hier wird eine Lösung beschrieben.

Kurzfassung:

wget http://files.spacefish.biz/LinuxPkg-5.15rc1.tar.bz2
tar xvfj LinuxPkg-5.15rc1.tar.bz2
cd realtek-linux-audiopack-5.15

Bei Nicht-Ubuntu Systemen soll es wohl reichen, das install skript auszuführen, laut Readme.txt ist die Vorgehensweise etwas anders:

tar xvjf alsa-driver-1.0.23-5.15rc1.tar.bz2
cd alsa-driver-1.0.23
./configure –with-cards=hda-intel
make
sudo make install

Theoretisch kann man auch das install skript ausführen und den Fehler am Ende ignorieren, da es genau das selbe macht. Nach einem Neustart noch im alsamixer alle Kanäle „unmuten“.

Schlankes XBMC unter Ubuntu Server

Zur Installation von Ubuntu gibt es im Netz genügend Quellen und Anleitungen, die jeder an seine eigenen Bedürfnisse (RAID, LVM, Verschlüsselung) anpassen kann. Aus diesem Grund setze ich eine frische Installation voraus. Bei der Installation wurde der Nutzer xbmc angelegt.

1. Netzwerk

Da in diesem Setup auf die Installation einer grafischen Oberfläche wie Gnome oder KDE verzichtet wird, muss die Konfiguration über die Shell und nicht z.B. den Network Manager erfolgen. Im Wiki findet man eine passende Anleitung für die Einrichtung einer WLAN Verbindung mittels wpa_supplicant. Je nach WLAN Chip, kann es nötig sein, Kernelmodule zu laden bzw. zu blacklisten.

Als Beispiel hier die Konfiguration (/etc/network/interfaces) für ein WLAN mit WPA2 Verschlüsselung und fester IP:

auto lo
iface lo inet loopback auto wlan0

iface wlan0 inet static
address 192.168.1.2
gateway 192.168.1.1
dns-nameservers 8.8.8.8
netmask 255.255.255.0
wpa-driver wext
wpa-ssid WLAN
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP TKIP
wpa-group CCMP TKIP
wpa-key-mgmt WPA-PSK
wpa-psk _HIER_WPA2_KEY_EINTRAGEN_

 

2. Autologin

Als nächstes wird das automatische Anmelden eingerichtet. Dazu wird rungetty installiert

aptitude install rungetty

und anschließend in der Datei /etc/init/tty1.conf, die Zeile

exec /sbin/getty 38400 tty1

durch die folgende ersetzt

exec /sbin/rungetty –autologin BENUTZERNAME tty1

Dabei natürlich BENUTZERNAME durch euren Benutzer ersetzen. In diesem Kontext also mit xbmc.

 

3. Xorg & nvidia

Installation des Xservers und der proprietären Nvidia Grafiktreiber

aptitude install xorg aptitude install nvidia-current

Evtl. reicht anschließend der Aufruf von

nvidia-xconfig

um eine geeignete Grundkonfiguration für den Xserver zu erstellen.

Hier meine /etc/X11/xorg.conf für eine Geforce GT220 und einen LG 37LH4000 LCD-TV.

Section „ServerLayout“
Identifier     „Prop. Nvidia“
Screen      0  „Screen“ 0 0
EndSection

Section „ServerFlags“
Option      „Xinerama“ „off“
EndSection

Section „Module“
Load    „glx“
EndSection

Section „Monitor“
Identifier  „LG LCD“
Option      „VendorName“ „LG“
Option      „ModelName“ „37LH4000“
Option      „DPMS“ „true“
Option      „PreferredMode“ „1920×1080“
Option      „Position“ „0 0“
Option      „Rotate“ „normal“
Option      „Disable“ „false“
Option      „TargetRefresh“ „50“
Option      „DPI“ „180 x 180“
EndSection

Section „Device“
Identifier  „Geforce GT220“
Driver  „nvidia“
Option  „NoLogo“                „true“
Option  „DynamicTwinView“       „false“
Option  „FlatPanelProperties“   „Scaling = Native“
Option  „ModeValidation“        „NoVesaModes, NoXServerModes“
Option  „ModeDebug“             „true“
Option  „HWCursor“              „false“
EndSection

Section „Screen“
Identifier „Screen“
Device     „Geforce GT220“
Monitor    „LG LCD“
DefaultDepth     24
SubSection „Display“
Depth     24
Modes  „1920x1080_50“ „1920x1080_60_0“ „1920x1080_30“ „1920x1080_25“ „1920x1080_24“  „1920x1080_50i“ „1920x1080_60i“
EndSubSection
EndSection

Section „DRI“
Mode         0666
EndSection

 

4. Sound

Wir verwenden zur Tonausgabe ALSA, diese erfolgt über die onboard Soundkarte, genauer: über den optischen Digitalausgang an einen externen Verstärker. Wer den Ton über hdmi ausgeben möchte, findet hier oder hier evtl. Hilfe.

aptitude install alsa-base alsa-utils
alsamixer

Im Alsamixer alle Spuren am besten ein wenig aufdrehen. Darauf achten, dass unter den Spuren kein MM steht. Das bedeutet, dass die Spur gemutet ist. Zum „laut schalten“ die Spur auswählen und m drücken. Außerdem muss der Benutzer noch zur audio Gruppe hinzugefügt werden. Dies passiert mit

usermod -a -G audio xbmc

 

5. XBMC

Das xbmc Repository hinzufügen

aptitude install python-software-properties
add-apt-repository ppa:team-xbmc/ppa
aptitude update

und anschließend die standalone version von xbmc mit allen Abhängigkeiten installieren

aptitude install xbmc-standalone

Den korrekten Start kann man nun mit

xinit xbmc-standalone

testen. Damit das xbmc zukünftig automatisch gestartet wird, fügen wir die Zeilen

if [ -z „$DISPLAY“ ] && [ $(tty) == /dev/tty1 ]; then
xinit /usr/bin/ck-launch-session /usr/bin/xbmc-standalone
fi

in die Datei .bash_profile ein.

 

6. Fernbedienung mit Lirc

Verwendet wird die HP Media Center Fernbedienung (diese hier), welche von lsusb als

Bus 004 Device 002: ID 0471:0815 Philips eHome Infrared Receiver

erkannt wird. Nach der Installation von lirc mittels

aptitude install lirc

sollte automatisch der Konfigurationsdialog starten. Für die oben genannte Fernbedienung

Windows Media Center Transceivers/Remotes (all)

und

Microsoft Windows Media Center V2 (usb) : Direct TV Receiver

auswählen. Abschließend den lirc daemon noch zum Autostart hinzufügen:

update-rc.d lirc enable default

Im xbmc sollte keine weitere Konfiguration nötig sein.

 

7. Power Management

Das udisks Paket mit allen Abhängigkeiten mittels

aptitude install udisks

installieren und die Datei /var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla mit dem Inhalt

[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
ResultActive=yes

erstellen.

Jetzt nur noch das xbmc selbst einrichten und das war es. Viel Vergnügen!

Quellen:
http://wiki.ubuntuusers.de/autologin
http://wiki.xbmc.org/?title=XBMCbuntu
http://wiki.xbmc.org/index.php?title=HOW-TO_install_XBMC_for_Linux_on_Ubuntu_with_a_minimal_installation,_an_unofficial_Step-by-Step_Guide
http://forum.xbmc.org/showthread.php?t=38804
http://wiki.ubuntuusers.de/lirc
http://wiki.xbmc.org/index.php?title=Ubuntu_Suspend_/_Wake
http://forum.xbmc.org/showthread.php?t=73236
http://www.loggn.de/ubuntu-xbmc-10-0-dharma-pvr-repository/

SSH keys nachträglich mit einem Passwort schützen

Hat man sich einmal an die Vorteile von public key Authentifizierung bei einem System gewöhnt, stellt man meist zügig alle anderen Systeme ebenfalls auf diese Art der Authentifizierung um. Möchte man sich von verschiedenen Systemen aus anmelden, muss der eigene private Key auf diese kopiert oder z.B. per USB-Stick mit sich geführt werden. Kommt dieser allerdings in falsche Hände, muss man einen neuen Schlüssel generieren und erneut an alle Systeme verteilen. Zum Schutz des privaten Keys, ist es möglich, diesen mit einem Passwort (besser: Passphrase) zu schützen. Dieses wird benötigt um den Key „freizuschalten“, die eigentliche Anmeldung am entfernten System läuft weiterhin über das public key Verfahren und benötigt kein Passwort.  Für eine einfachere Unterscheidung wird das Kennwort zur Freischaltung deshalb auch als „Passphrase“ und nich als Passwort bezeichnet. Sollte man den privaten Schlüssel bei der Erstellung nicht mit einer Passphrase versehen haben, kann man dies noch nachträglich mit ssh-keygen tun.

[pat@earth ~]$ ssh-keygen -p
Enter file in which the key is (/home/pat/.ssh/id_rsa):  [Enter]
Key has comment ‚/home/pat/.ssh/id_rsa‘
Enter new passphrase (empty for no passphrase):  newSuperSavePassword
Enter same passphrase again:  newSuperSavePassword
Your identification has been saved with the new passphrase.

Quellen:

http://kimmo.suominen.com/docs/ssh/#passwd

http://www.manpagez.com/man/1/ssh-keygen/

VPN einrichten mit pptpclient / pptp-linux

Für den Netzzugang über ein virtuelles privates Netz (VPN) gibt es sicherlich eine ganze Menge guter Gründe, einer davon ist z.B. die Überwindung der geobasierten Sperrung von Webseiten à la Youtube („Dieses Video ist in deinem Land nicht verfügbar“). Auf Amerika beschränkte Angebote wie der Streaming Dienst Hulu sind damit in Deutschland nutzbar. Der Anbieter VPN on Demand befindet sich seit einiger Zeit in der Betaphase und ermöglicht einen kostenlosen VPN Zugang. Dazu einfach eine E-Mail mit dem Betreff „vpnod“ an promotion@vpnod.com schicken und kurze Zeit später gibt es die Zugangsdaten per E-Mail.

Als erstes muss der PPTP-Client installiert werden. Unter Arch Linux mittels

[pat@earth ~]$ sudo pacman -S pptpclient

unter Debian und Ubuntu heißt das Paket pptp-linux und wird mittels

[pat@earth ~]$ sudo aptitude install pptp-linux

installiert. Nach der Installation konfigurieren wir eine neue VPN Verbindung, hier im Beispiel von VPN on Demand. Dazu legen wir im Verzeichnis /etc/ppp/peers eine Datei für die neue VPN-Verbindung an und tragen folgendes ein: (Die im folgenden verwendeten Variablen $BENUTZER und $PASSWORT sind natürlich mit den erhaltenen Zugangsdaten zu ersetzen)

[pat@earth ~]$ sudo vim /etc/ppp/peers/vpnod

pty „pptp vpn.vpnod.com –nolaunchpppd“
name $USER
linkname vpnod
remotename vpnod
ipparam vpnod
usepeerdns
require-mppe-128
file /etc/ppp/options.pptp

In der Datei chap-secrets werden nun die Zugangsdaten definiert.

[pat@earth ~]$ sudo vim /etc/ppp/chap-secrets

$BENUTZER vpnod $PASSWORT *

Zum testen starten wir das VPN und setzen die Schnittstelle als Standardgateway, so dass der gesamte Internetverkehr über das VPN läuft. Am besten vorher und nachher diese Seite zur Überprüfung der eigenen IP besuchen. Hinweis: Ab diesem Zeitpunkt wird jeglicher Traffic über das VPN geroutet, d.h. auch E-Mails, Instant Messenger oder andere Anwendungen die auf dem System laufen. Die Daten sind zwar bis zur VPN Gegenstelle verschlüsselt, ab dort ist es allerdings Aufgabe des Anwenders für die Verschlüsselung zu sorgen. Wer dem VPN Anbieter nicht traut (oder leicht zu Paranoia neigt :) ) sollte hier die selben Sicherheitsvorkehrungen wie bei der Nutzung eines öffentlichen WLAN Hotspots, sprich HTTPS/SSL, vornehmen.

[pat@earth ~]$ sudo pon vpnod
[pat@earth ~]$ sudo route add default dev ppp0

Sollte der Verbindungsaufbau scheitern, kann der Aufruf von pon mittels

[pat@earth ~]$ sudo pon vpnod debug dump logfd 2 nodetach

bei der Fehlersuche hilfreich sein.

Zum Abbau der Verbindung, die Route wieder entfernen (sollte poff automatisch machen) und die Verbindung trennen.

[pat@earth ~]$ sudo route del default
[pat@earth ~]$ sudo poff

Klappt alles ohne Probleme, kann man das ganze nun automatisieren. Alle Scripte (*.sh) im Ordner /etc/ppp/if-up.d/ werden automatisch nach dem Aufbau der VPN Verbindung ausgeführt. Da Rounting eine komplexe Sache und ein Post für sich wäre, hier nur beispielhalt ein Script zum routen des gesammten Traffics über das VPN.

pat@earth ~]$ sudo vim /etc/ppp/ip-up.d/10-route.sh

#!/bin/bash

# Interface (eth0 or wlan0 in most cases)
INTERFACE=eth0

# Interface as provided by calling pppd
VPN=$1
#VPN=ppp0

route del default ${INTERFACE}
route add default dev ${VPN}

Und erstellen ein weiteres Script, welches nach dem Abbau der VPN Verbindung wieder die richtige Route einträgt.

[pat@earth ~]$ sudo vim /etc/ppp/ip-down.d/10-route.sh
#!/bin/bash

# Interface (eth0 or wlan0 in most cases)
INTERFACE=eth0

# Interface as provided by calling pppd
VPN=$1

# Gateway (use ‚route‘ to find out, IP or name)
GATEWAY=192.168.2.1

route del default ${VPN}
route add default gw ${GATEWAY} ${INTERFACE}

Ist der Hostname oder die IP des Gateways nicht bekannt, hilft das Kommando route.

[pat@earth ip-up.d]$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 202 0 0 eth0
default 192.168.2.1 0.0.0.0 UG 202 0 0 eth0

Eine Möglichkeit das Ganze nun automatisch beim Systemstart zu machen, findet man für Arch Linux z.B. hier.

Quellen: http://pptpclient.sourceforge.net