Vpn Ppp Gateway - L2TP

Vpn Ppp Gateway

Ho creato una macchina virtuale che facesse da gateway per la mia rete locale in modo da avere la connessione in vpn tramite ppp solo su quella macchina opportunamente configurata e lasciare gli altri dispositivi della rete sgravati dalle configurazioni di ppp

Configurazione di ppp

Ho preso le info da qui http://www.cyberciti.biz/tips/howto-configure-ubuntu-fedora-linux-pptp-client.html
Io ho usato una macchina linux

apt-get install pptp-linux network-manager-pptp

dovrebbe bastare solo il primo pacchetto in quando ho usato solo la parte testuale

Impostazione di username e password

nano /etc/ppp/chap-secrets 
# Secrets for authentication using CHAP
# client    server    secret            IP addresses
miousername PPTP miapassword *

Impostazioni delle info di configurazione

nano /etc/ppp/peers/nomeconnessione
pty "pptp mio.dominio.it --nolaunchpppd"
name miousername
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam nomeconnessione

Impostazioni del routing

nano /etc/ppp/ip-up.d/route-traffic 
#!/bin/bash
NET="10.159.51.0/24" # set me
IFACE="ppp0" # set me
#IFACE=$1
route add -net ${NET} dev ${IFACE}

Finalizziamo le impostazioni e avviamo la vpn

chmod +x /etc/ppp/ip-up.d/route-traffic
pppd call nomeconnessione
tail -f /var/log/syslog

Chiudere

killall pppd

Aggiungere le funzionalità di routing

Per fare in modo che la macchina faccia da router deve permettere l'instradamento dei pacchetti e deve mascherare il fatto che i pacchetti non provengano da lei in modo che le info sull'interfaccia ppp appaiano con indirizzo sorgente che sia il terminatore della vpn e non l'ip di rete locale.
Le interfacce sono eth0 da dove vengono i pacchetti e ppp0 l'interfaccia dove sono diretti
Servono questi due comandi

echo 1 >> /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

Sul router della rete locale lan invece serve la regola di routing che mandi le info attraverso la macchina che funge da gateway.
Sul mio router che ha shorewall ho aggiunto a /etc/shorewall/routes
main            10.159.51.0/24         192.168.9.174

dove 192.168.9.174 è l'ip della macchina che fa da gateway

L2TP (install client on ubuntu)

it was very difficult configure for many reasons

Install the client

the mainly guide is this http://bailey.st/blog/2011/07/14/connecting-to-a-l2tpipsec-vpn-from-ubuntu-desktop/

Enable notification area

  • In gnome3 classic on ubuntu 12.04 you must enable the notification area that is disable by default here there is a good article to do this

http://askubuntu.com/questions/121426/no-banshee-notification-area-icon-in-gnome-3-classic-session . (keep press alt+win buttons and right click to the top bar , add to panel, notification area,)

  • In gnome3 standard instead you can see the icon in the notification area in the bottom when you pass the mouse over
notification%20area.png

Open the connection editor from command line

in the guides is written to reboot every modify but it's not necessary , the process to restart the icon is this http://manpages.ubuntu.com/manpages/precise/man1/L2tpIPsecVpn.1.html
you can run with the options or without , in the guide there are little errors , there are not the first letters of the options but is easily guess it
for example to open the connection editor

root@peppelaptop:~# L2tpIPsecVpn startConnectionEditor
Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License