Wordpress Themes

[HOW TO] VPN con Vtun fra Debian 5 e Ubuntu 9.04

servono pochi passi per instaurare un tunnel fra due macchine usando il comodo tool Vtun, presente in entrambe le distribuzioni con la versione 3.0.2-1.1.

tenendo presente che ‘S‘ sarà il nostro server, e ‘C ‘ il client (Vtun può agire indifferentemente sia come C che come S) proviamo a creare questo tunnel criptato, che ci potrà essere utile per far comunicare due reti differenti utilizzando Internet.

Questi gli IPs che usiamo nell’esempio:

S: 192.168.200.1 (Debian 5 – Lenny)
C: 192.168.200.2 (Ubuntu 9.04  – Jaunty Jackalope)

andremo a creare il device tun0 utilizzando come protocollo TCP.

partiamo.

S,C: (fate attenzione agli apici del comando echo che non sono visualizzati correttamente da Wordpress)

# aptitude install vtun ; modprobe tun && echo -e ‘# VTUN\ntun\n’ >> /etc/modules

S: editare /etc/vtund.conf

options {
type stand;
port 5000;
timeout 60;
ppp /usr/sbin/pppd;
ifconfig /sbin/ifconfig;
route /sbin/ip;
firewall /sbin/iptables;
}

default {
type tun;
proto tcp;
compress lzo:9;
encrypt yes;
keepalive yes;
speed 0;
stat yes;
}

tunneltest {
encrypt yes;
compress yes;
password supersecret;
type tun;
device tun0;
up {
ifconfig “%% 192.168.200.1 pointopoint 192.168.200.2″;
route “add -net 192.168.200.0 gw 192.168.200.2″;
};
down{
ifconfig “%% down”;
};

}

S: editare /etc/default/vtun

RUN_SERVER=yes
SERVER_ARGS=”-P 5000″

C: editare /etc/vtund.conf

options {
type stand;
port 5000;
timeout 60;
ppp /usr/sbin/pppd;
ifconfig /sbin/ifconfig;
route /sbin/ip;
firewall /sbin/iptables;
}

default {
type tun;
proto tcp;
compress lzo:9;
encrypt yes;
keepalive yes;
speed 0;
stat yes;
}

tunneltest {
encrypt yes;
compress yes;
password supersecret;
type tun;
device tun0;
up {
ifconfig “%% 192.168.200.2 pointopoint 192.168.200.1″;
route “add -net 192.168.200.0 gw 192.168.200.1″;
};
down{
ifconfig “%% down”;
};

}

C: editare /etc/default/vtun mettendo l’IP pubblico del server al quale connettersi

CLIENT0_NAME=tunneltest
CLIENT0_HOST=123.123.123.123

quasi finito, ora serve aprire su S la porta 5000 TCP al C che si deve connettere: mentre che avete i comandi di iptables fra le dita dovreste anche aggiungere le rules fra i due hosts via tunnel (classe 192.168.250.0/24). ora:
S,C:

# /etc/init.d/vtun restart

S,C:

adesso dando un ‘ifconfig‘ o ‘ip a‘ dovreste vedere UP un certo ‘tun0‘.

ovviamente questo è solo un esempio d’uso di Vtun, le opzioni su cui giocare sono molteplici, se vi ho incuriosito e volete saperne di più leggete la documentazione.

Leave a comment

Please be polite and on topic. Your e-mail will never be published.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word