[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

¡Esta es una revisión vieja del documento!


En proceso de traducción. Disculpe las molestias.rramp

VPN con Tinc

Tinc es un software de código abierto para crear redes privadas virtuales (VPN), las VPN a través de otro canal físico como Internet, donde los hosts (nodos) participantes individuales aparecen en las aplicaciones como si estuvieran conectados por cable en LAN.

Tinc is open source software for creating VPNs, virtual private networks over other physical channel such as the Internet, where individual participating hosts (nodes) appear to applications as if connected by wire in LAN.

Visión general

Tinc utiliza criptografía asimétrica. Cada nodo tiene su propia llave privada, una llave publica y otra llave publica; para cada participante del nodo. Estos archivos son, junto con algunos archivos de configuración, almacenados en el directorio /etc/tinc/<nombre de la VPN>.

Tinc utilizes asymmetric cryptography. Each node has its own private key, a public key and another public key; one for each participating node. These files are, together with a few configuration files, stored in /etc/tinc/<VPN name> directory.

Cada nodo también corre como un demonio (o múltiples demonios, uno para cada VPN por separado). Los demonios escuchan sobre el puerto configurado (por defecto es 655) para conexiones entrantes desde otros nodos. Each node also runs a daemon (or multiple daemons, one for each separate VPN). Daemon listens on set port (default is 655) for incoming connections from other nodes. Solo los nodos con claves privadas validas pueden producir datos descifrables con claves publicas que coincidan y de esta forma se concede el acceso. Only nodes with valid private keys can produce data decipherable with matching public keys and are thus granted access.

El archivo de clave pública puede contener no solo la clave en sí, sino también la dirección IP pública (y el puerto) del nodo al que pertenece. Public key file may contain not only key itself, but also public IP address (and port) of node to which it belongs. Si se configura, el demonio no esperará las conexiones, pero intentará conectarse a estos nodos conocidos. If set to, daemon will not wait for connections, but will attempt to connect to these known nodes.

Cada nodo tiene su propia dirección IP (en el espacio de direcciones privado) que, una vez que el demonio se está ejecutando, se asigna a la interfaz de red virtual. Each node has its own IP address (in private address space) which, once the daemon is running, is assigned to virtual network interface. Cualquier tráfico proveniente de la VPN es procesado por el demonio y proviene de esa interfaz de red, y cualquier tráfico enviado a través de esa interfaz también es procesado por el demonio y enviado a la VPN, de forma totalmente transparente para las aplicaciones. Any traffic coming from VPN is processed by the daemon and made come from that network interface, and any traffic send through that interface is also processed by the daemon and sent to VPN, all behind the scenes, transparent to applications. Una característica importantes de Tinc es que el demonio puede (y por defecto lo hace) reenviar tráfico para otros nodos, por ejemplo, si los nodos A y B están detrás de NAT y pueden comunicarse directamente solo con el nodo C, que tiene acceso irrestricto a Internet, o incluso no saben la clave pública de cada uno, pero C los conoce a ambos, C felizmente reenviará el tráfico entre ellos / para ellos. Important feature of Tinc is that daemon can (and by default does) forward traffic for other nodes, e.g. if nodes A and B are behind NAT and can directly communicate with only node C, which has unrestricted internet access, or even do not know public key of each other, but C knows them both, C will happily forward traffic between/for them.

Sólo necesitan saber las direcciones IP (en el espacio de direcciones privadas). They just need to know IP addresses (in private address space).

Instalación

# ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
# make
# make install
  • Si prefiere tener Tinc en algún lugar aparte, cambie el prefijo. Pruebe DESTDIR si desea instalar temporalmente en otro lugar:
  • If you prefer to have Tinc somewhere aside, change prefix. Try DESTDIR if you want to temporarily install somewhere else:
$ make DESTDIR=/somewhere/else install

Configuración

  • Cree la configuración inicial (también genera claves privadas y públicas para el nodo), lo que significa que el directorio en /etc/inc lleva el nombre de VPN con algunos archivos iniciales.
  • Either create initial configuration (also generates private and public keys for node), which means directory in /etc/tinc named after VPN with some initial files it.
# tinc -n VPNtest init node1
  • O genere sólo llaves pares privadas/publicas. Ubique las llaves privadas en /etc/tinc/<Nombre de la VPN>, fusionar las claves públicas en un archivo y colocarlas más adelante en un subdirectorio /etc/tinc/<nombre de la VPN>/hosts.
  • Or generate only private/public key pairs. Place private keys to /etc/tinc/<VPN name>, merge public keys into one file and place it further into subdirectory /etc/tinc/<VPN name>/hosts.
$ tinc -c . generate-keys
$ mkdir -p VPNtest/hosts
$ mv *.priv VPNtest/.
$ cat rsa_key.pub ecdsa_key.pub > VPNtest/hosts/node1
$ rm rsa_key.pub ecdsa_key.pub
  • Ajuste de la configuración en /etc/tinc/<VPN name>/tinc.conf. Saltar el parámetro ConnectTo si el demonio debe esperar pasivamente las conexiones. El nombre de la tarjeta de red virtual es configurado en el parámetro Interface, ver más abajo. Opcionalmente, configure el puerto de escucha, especialmente si desea ejecutar varios demonios/VPNs.

* Fine-tune configuration in /etc/tinc/<VPN name>/tinc.conf. Skip ConnectTo if deamon should passively wait for connections. Interface is name of virtual network card, see more below. Optionally set listening port, especially if you intend to run multiple daemons/VPNs.

tinc.conf
Name = node1
ConnectTo = node2
Interface = vpnNIC
Port = 6655
  • Configure interfaces de red virtuales en /etc/tinc/<VPN name>/tinc-up. No cree manualmente interfaces (via el comando ip), el demonio Tinc puede hacer esto por usted, simplemente escriba la configuración para el nivel de IP. Además, haga que el archivo de tinc-up sea ejecutable.

* Configure virtual network interface in /etc/tinc/<VPN name>/tinc-up. Do not manually create interface (via ip command), Tinc daemon will do that for you, just write down configuration for IP level. Also, make tinc-up file executable.

tinc-up
#!/bin/sh
ip addr add 192.168.1.1/24 dev vpnNIC
ip link set vpnNIC up
  • Ajuste el archivo de claves publicas en /etc/tinc/<VPN name>/hosts/<este nodo>. La IP pública puede ser también un nombre de host/dominio, lo cual es conveniente en caso de que, por ejemplo cambie de ISP, pero que conserve el nombre de DNS. El puerto debe ser el mismo que en tinc.conf, pero puede diferir si por ejemplo está detrás de NAT con reenvío de puerto a otro número de puerto. Deje que otros nodos tengan este archivo y coloque sus archivos de clave pública aquí.

* Fine-tune public key file in /etc/tinc/<VPN name>/hosts/<this node>. Public IP may be also a hostname/domain, which is convenient in case you e.g. change ISP, but keep DNS name. Port should be same as in tinc.conf, but may differ if e.g. you are behind NAT with port forwarding from one port number to different port number. Let other nodes have this file and place their public key files here.

node1
Address = <public IP address> [port]
Subnet = 192.168.1.1/32
-----BEGIN RSA PUBLIC KEY-----
...
  • Repita el proceso sobre (o por) otros nodos, use diferente nombre para los nodos y diferentes espacios de IPs. Nuevamente, permita que los nodos tengan el archivo de clave pública (o host) del otro.

* Repeat process on (or for) other nodes, use different names for nodes and different private space IPs. Again, let nodes have each other's public key (or host) file.

  • Inicie el demonio, opcionalmente especifique el nivel de debug (0-5 donde 5 es el más elocuente) y donde se registra en un archivo.

* Start daemon, optionally specify debug level (0-5 where 5 is most eloquent) and where-to-log file.

# tincd -n VPNtest --debug=5 --logfile=/var/log/VPNtest.log

Windows

En aras de la integridad, como por ejemplo, construir una VPN con una máquina Linux como servidor de archivos al que acceda Windows, administrar remotamente un grupo de Windows detrás de NAT de Linux, jugar a juegos, lo que sea, vamos a cubrir también Windows (XP, 7 y 8 son conocidos por su funcionamiento). For sake of completeness, as you might want to e.g. build a VPN with Linux machine as fileserver accessed by Windows, remote-manage bunch of Windows behind NAT from Linux, play games, whatever, let's cover also Windows (XP, 7 and 8 are known to work).

Instalación

  • Descargar los paquetes binarios.
  • Instalar el software Tinc.
  • Preferentemente desinstale algún posible dispositivo TUN/TAP (NICs virtuales). Tapinstall es parte del paquete de Tinc, debe estar en su directorio de instalación en alguna parte.
  • Preferably uninstall any possible existing TUN/TAP devices (virtual NICs). Tapinstall utility is part of Tinc package, should be in its install dir somewhere.
C:\path\to\tapinstall.exe remove tap0901
  • Instalar nuevos dispositivos TUN/TAP device.
C:\path\to\tapinstall.exe install OemWin2k.inf tap0901
  • Device drivers actually seem to come from OpenVPN project. Which is good, because they are signed; Windows are quite hostile towards unsigned drivers lately.

Configuración

There are a few differences in Windows configuration.

  • You still generate initial configuration files, but place them in into where Tinc is installed, which should be something like C:\Program Files\tinc\<VPN name>
  • In tinc.conf, omit Interface directive, because Tinc daemon will then automatically select TUN/TAP device and directive may do more harm than good. Especially if Tinc service starts and fails immediately, check that Interface is not set.
  • Tinc-up script is not used on Windows. You created persistent TUN/TAP device during installation (did you?) and now only manually configure IP (run ncpa.cpl, see properties of device and so on). This can be also scripted with command such as:
netsh interface ip set address name="Local Area Connection number" static <IP address> <mask>
  • But be warned: when created, TUN/TAP device can aquire pretty much any number in name, most likely 2, but not always.
  • Finally, install (and start) Tinc service:
C:\path\to\tincd.exe --debug=5 --logfile=C:\path\to\file.log -n VPNtest
  • Or, if service already exists, start service:
cmd> net start tinc.VPNtest

script RC

Aquí hay algunos scripts para iniciar todas las VPNs en el arranque.

#!/bin/sh
 
VPNS=$(ls /etc/tinc)
 
start () {
	for VPN in $VPNS; do
		echo "Starting tinc daemon for $VPN..."
		/usr/sbin/tincd -n "$VPN" -d1 --logfile=/var/log/tinc."$VPN"
	done
}
 
stop () {
	for VPN in $VPNS; do
		echo "Stopping tinc daemon for $VPN..."
		/usr/sbin/tinc -n "$VPN" stop
	done
}
 
restart () {
	stop
	sleep 1
	start
}
 
case "$1" in
	("start")
		start
		;;
	("stop")
		stop
		;;
	("restart")
		restart
		;;
	(*)
		echo "Usage: $0 <start|stop|restart>"
		exit 1
esac
 
exit 0

Salve esto como por ejemplo /etc/rc.d/rc.tinc, hacer ejecutable y luego agregar una línea a rc.local.

rc.local
/etc/rc.d/rc.tinc start

Fuentes

Documentación/sitio web de Tinc http://www.tinc-vpn.org

 es:howtos:network_services:tinc ()
Esta traducción es más antigua que la página original y podría estar obsoleta. Ver lo que ha cambiado.