tun
(para túneles a nivel de IP) y tap
(para túneles a nivel Ethernet). En la práctica, usualmente utilizará interfaces tun
excepto cuando los clientes VPN deban intengrarse a la red local del servidor a través de un puente Ethernet.
openssl
; puede encontrar estos scripts bajo /usr/share/doc/openvpn/examples/easy-rsa/2.0/
.
$
cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 pki-falcot
$
cd pki-falcot
vars
, especialmente aquellos cuyos nombres comienzan con KEY_
; estas variables luego son integradas en el entorno:
$
vim vars
$
grep KEY_ vars
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA` export KEY_DIR="$EASY_RSA/keys" echo NOTE: If you run ./clean-all, I will be doing a rm -rf on $KEY_DIR export KEY_SIZE=2048 export KEY_EXPIRE=3650 export KEY_COUNTRY="FR" export KEY_PROVINCE="Loire" export KEY_CITY="Saint-Étienne" export KEY_ORG="Falcot Corp" export KEY_EMAIL="admin@falcot.com" $
. ./vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /home/rhertzog/pki-falcot/keys $
./clean-all
keys/ca.crt
y keys/ca.key
):
$
./build-ca
Generating a 2048 bit RSA private key ..............................................++++++ .......................++++++ writing new private key to 'ca.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [Falcot Corp CA]: Name []: Email Address [admin@falcot.com]:
vpn.falcot.com
; se reutiliza este nombre para los archivos de llaves generados (keys/vpn.falcot.com.crt
para el certificado público, keys/vpn.falcot.com.key
para la llave privada):
$
./build-key-server vpn.falcot.com
Generating a 2048 bit RSA private key ...............++++++ ...........++++++ writing new private key to 'vpn.falcot.com.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [vpn.falcot.com]: Name []: Email Address [admin@falcot.com]: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /home/rhertzog/pki-falcot/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'FR' stateOrProvinceName :PRINTABLE:'Loire' localityName :T61STRING:'Saint-\0xFFFFFFC3\0xFFFFFF89tienne' organizationName :PRINTABLE:'Falcot Corp' commonName :PRINTABLE:'vpn.falcot.com' emailAddress :IA5STRING:'admin@falcot.com' Certificate is to be certified until Oct 9 13:57:42 2020 GMT (3650 days) Sign the certificate? [y/n]:
y
1 out of 1 certificate requests certified, commit? [y/n]
y
Write out database with 1 new entries Data Base Updated $
./build-dh
Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ..............+.......+.................................++*++*++*
$
./build-key JoeSmith
Generating a 2048 bit RSA private key ................++++++ .............................++++++ writing new private key to 'JoeSmith.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [FR]: State or Province Name (full name) [Loire]: Locality Name (eg, city) [Saint-Étienne]: Organization Name (eg, company) [Falcot Corp]: Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) [JoeSmith]:
Joe Smith
Name []: Email Address [admin@falcot.com]:
joe@falcot.com
[…]
key/ca.crt
) será almacenada en todas las máquinas (tanto el servidor como los clientes) como /etc/ssl/certs/Falcot_CA.crt
. Sólo instalará el certificado del servidor en el servidor (key/vpn.falcot.com.crt
en /etc/ssl/vpn.falcot.com.crt
y key/vpn.falcot.com.key
en /etc/ssl/private/vpn.falcot.com.key
con permisos restringidos para que sólo el administrador pueda leerlo), con los parámetros Diffie-Hellman correspondientes (key/dh2048.pem
) instalados en /etc/openvpn/dh2048.pem
. Instale los certificados de clientes en el cliente de VPN correspondiente de forma similar.
/etc/openvpn/*.conf
. Configurar un servidor VPN entonces es cuestión de almacenar el archivo de configuración correspondiente en este directorio. Un buen punto de partida es /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz
que lleva a un servidor bastante estándar. Por supuesto necesitará adaptar algunos parámetros: ca
, cert
, key
y dh
describirán las ubicaciones seleccionadas para cada uno (respectivamente: /etc/ssl/certs/Falcot_CA.crt
, /etc/ssl/vpn.falcot.com.crt
, /etc/ssl/private/vpn.falcot.com.key
y /etc/openvpn/dh2048.pem
). La directiva server 10.8.0.0 255.255.255.0
define la subred utilizada por la VPN; el servidor utilizará la primera dirección IP en el rango (10.8.0.1
) y se asignarán a los clientes el resto de las direcciones.
tun0
. Sin embargo, normalmente se configuran los firewalls al mismo tiempo que las interfaces de red reales, lo que ocurre antes que inicie OpenVPN. La creación de una interfaz de red virtual persistente, y configurar OpenVPN para que la utilice, es una buena práctica recomendada. Esto además permite elegir el nombre de esta interfaz. A tal efecto, openvpn -mktun -dev vpn -dev-type tun
crea una interfaz de red virtual llamada vpn
de tipo tun
; puede integrar fácilmente esta orden en el script de configuración del firewall o en la directiva up
del archivo /etc/network/interfaces
. Debe actualizar también el archivo de configuración de OpenVPN de forma acorde, con las directivas dev vpn
y dev-type tun
.
10.8.0.1
. Para permitir a los clientes que accedan la red local (192.168.0.0/24) necesitará agregar una directiva push route 192.168.0.0 255.255.255.0
a la configuración de OpenVPN para que los clientes VPN automáticamente obtengan una ruta de red que les indique que esta red está disponible a través de la VPN. Lo que es más, los equipos en la red local también necesitarán ser informados que la ruta a la VPN es a través del servidor de VPN (esto funciona automáticamente cuando instala el servidor VPN en la puerta de enlace). Otra alternativa es configurar el servidor VPN para realizar enmascaramiento de IPs de forma que las conexiones que provengan de los clientes VPN parezcan provenir del servidor VPN en su lugar (revise la Sección 10.1, “Puerta de enlace”).
/etc/openvpn/
. Puede conseguir una configuración estándar utilizando /usr/share/doc/openvpn/examples/sample-config-files/client.conf
como punto de partida. La directiva remote vpn.falcot.com 1194
describe la dirección y puerto del servidor OpenVPN; también necesita adaptar ca
, cert
y key
para describir la ubicación de los archivos de llave.
AUTOSTART
como none
en el archivo /etc/default/openvpn
. Siempre es posible iniciar o detener una conexión VPN dada con /etc/init.d/openvpn start nombre
y /etc/init.d/openvpn stop nombre
(donde la conexión nombre coincide con aquella definida en /etc/openvpn/nombre.conf
).
tun*
) on both sides of an SSH connection, and these virtual interfaces can be configured exactly as if they were physical interfaces. The tunneling system must first be enabled by setting PermitTunnel
to “yes” in the SSH server configuration file (/etc/ssh/sshd_config
). When establishing the SSH connection, the creation of a tunnel must be explicitly requested with the -w any:any
option (any
can be replaced with the desired tun
device number). This requires the user to have administrator privilege on both sides, so as to be able to create the network device (in other words, the connection must be established as root).
/etc/ipsec-tools.conf
de cada equipo contiene los parámetros de los túneles IPsec (en términos de IPsec: asociaciones de seguridad, «Security Associations») en los que el equipo está involucrado; el script /etc/init.d/setkey
provee una forma de iniciar y detener el túnel (cada túnel es un enlace seguro a otra máquina conectada a la red privada virtual). Puede construir este archivo a mano desde la documentación que provee la página de manual setkey(8). Sin embargo, escribir los parámetros para todos los equipos en un conjunto de máquinas no trivial se convierte fácilmente en una tarea ardua ya que la cantidad de túneles crece rápidamente. Instalar un demonio IKE (intercambio de llaves IPsec: «IPsec Key Exchange») como racoon, strongswan o openswan hace el proceso mucho más simple centralizando la administración y más seguro rotando las claves periódicamente.
/etc/ppp/options.pptp
, /etc/ppp/peers/falcot
, /etc/ppp/ip-up.d/falcot
y /etc/ppp/ip-down.d/falcot
.
Ejemplo 10.2. El archivo /etc/ppp/options.pptp
# PPP options used for a PPTP connection lock noauth nobsdcomp nodeflate
Ejemplo 10.3. El archivo /etc/ppp/peers/falcot
# vpn.falcot.com is the PPTP server pty "pptp vpn.falcot.com --nolaunchpppd" # the connection will identify as the "vpn" user user vpn remotename pptp # encryption is needed require-mppe-128 file /etc/ppp/options.pptp ipparam falcot
pptpd
es el servidor PPTP para Linux. Necesitará cambiar pocas cosas de su archivo de configuración principal, /etc/pptpd.conf
: localip (dirección IP local) y remoteip (dirección IP remota). En el ejemplo a continuación el servidor PPTP siempre utiliza la dirección 192.168.0.199
y los clientes PPTP reciben una dirección IP desde 192.168.0.200
a 192.168.0.250
.
Ejemplo 10.6. El archivo /etc/pptpd.conf
# TAG: speed # # Specifies the speed for the PPP daemon to talk at. # speed 115200 # TAG: option # # Specifies the location of the PPP options file. # By default PPP looks in '/etc/ppp/options' # option /etc/ppp/pptpd-options # TAG: debug # # Turns on (more) debugging to syslog # # debug # TAG: localip # TAG: remoteip # # Specifies the local and remote IP address ranges. # # You can specify single IP addresses separated by commas or you can # specify ranges, or both. For example: # # 192.168.0.234,192.168.0.245-249,192.168.0.254 # # IMPORTANT RESTRICTIONS: # # 1. No spaces are permitted between commas or within addresses. # # 2. If you give more IP addresses than MAX_CONNECTIONS, it will # start at the beginning of the list and go until it gets # MAX_CONNECTIONS IPs. Others will be ignored. # # 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238, # you must type 234-238 if you mean this. # # 4. If you give a single localIP, that's ok - all local IPs will # be set to the given one. You MUST still give at least one remote # IP for each simultaneous client. # #localip 192.168.0.234-238,192.168.0.245 #remoteip 192.168.1.234-238,192.168.1.245 #localip 10.0.1.1 #remoteip 10.0.1.2-100 localip 192.168.0.199 remoteip 192.168.0.200-250
/etc/ppp/pptpd-options
. Los parámetros importantes son el nombre del servidor (pptp
), el nombre del dominio (falcot.com
y la dirección IP para los servidores DNS y WINS.
Ejemplo 10.7. El archivo /etc/ppp/pptpd-options
## turn pppd syslog debugging on #debug ## change 'servername' to whatever you specify as your server name in chap-secrets name pptp ## change the domainname to your local domain domain falcot.com ## these are reasonable defaults for WinXXXX clients ## for the security related settings # The Debian pppd package now supports both MSCHAP and MPPE, so enable them # here. Please note that the kernel support for MPPE must also be present! auth require-chap require-mschap require-mschap-v2 require-mppe-128 ## Fill in your addresses ms-dns 192.168.0.1 ms-wins 192.168.0.1 ## Fill in your netmask netmask 255.255.255.0 ## some defaults nodefaultroute proxyarp lock
vpn
user (and the associated password) in the /etc/ppp/chap-secrets
file. Contrary to other instances where an asterisk (*
) would work, the server name must be filled explicitly here. Furthermore, Windows PPTP clients identify themselves under the DOMAIN\\USER
form, instead of only providing a user name. This explains why the file also mentions the FALCOT\\vpn
user. It is also possible to specify individual IP addresses for users; an asterisk in this field specifies that dynamic addressing should be used.