OpenVPN

De ProyectoFedora

"Borrador"

Contenido

Instalación Servidor OpenVPN

http://openvpn.net/ 
yum install openvpn

Autenticación con Certificado

Principio, cada usuario y/o pc cliente tiene su certificado para autenticarse y para ello debe erigirse como autoridad que emita dicho certificados. Abajo le ofrecemos una "receta" breve ya que no es un tema particular de OpenVPN del cómo se gestionan los certificados.

Creación del Servidor de Certificados

 # su -
 # mkdir /etc/openvpn/easyrsa
 # cp -ar /usr/share/openvpn/easy-rsa/2.0/* /etc/openvpn/easyrsa/
 # cd /etc/openvpn/easyrsa
 # vi vars
  # These are the default values for fields
  # which will be placed in the certificate.
  # Don't leave any of these fields blank.
  export KEY_COUNTRY="VE"
  export KEY_PROVINCE="DC"
  export KEY_CITY="Caracas"
  export KEY_ORG="gomix.org"
  export KEY_EMAIL="guillermo.gomez@gmail.com"
# cd /etc/openvpn/easyrsa 
# . vars 
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easyrsa/keys
# ./clean-all
# ./build-ca 
Generating a 1024 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) [VE]:
State or Province Name (full name) [DC]:
Locality Name (eg, city) [Caracas]:
Organization Name (eg, company) [gomix.org]:
Organizational Unit Name (eg, section) []:Ingenieria
Common Name (eg, your name or your server's hostname) [Gomix Org]:
Email Address [guillermo.gomez@gmail.com]:
#

Generación de Parámetros Diffie Hellman

# ./build-dh 
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
............+...................................................
................................................................
................................................................
..................+.............................................
................................................................
........................+.......................................
..............+............................................+...+
................................................................
............................................+.........++*++*++*
# 

Llaves del Servidor

 ./build-key-server mi.servidor.com
Generating a 1024 bit RSA private key
..................++++++
...............................++++++
writing new private key to 'mi.servidor.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) [VE]:
State or Province Name (full name) [DC]:
Locality Name (eg, city) [Caracas]:
Organization Name (eg, company) [Gomix Org]:
Organizational Unit Name (eg, section) []:Seguridad
Common Name (eg, your name or your server's hostname) [mi.servidor.com]:
Email Address [guillermo.gomez@gmail.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easyrsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'VE'
stateOrProvinceName   :PRINTABLE:'DC'
localityName          :PRINTABLE:'Caracas'
organizationName      :PRINTABLE:'Gomix Org'
organizationalUnitName:PRINTABLE:'Seguridad'
commonName            :PRINTABLE:'mi.servidor.com'
emailAddress          :IA5STRING:'guillermo.gomez@gmail.com'
Certificate is to be certified until Aug 19 23:57:44 2018 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


Llaves Para Clientes

 
# ./vars 
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easyrsa/keys
# ./build-key cmartinez
Generating a 1024 bit RSA private key
................++++++
....++++++
writing new private key to 'cmartinez.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) [VE]:
State or Province Name (full name) [DC]:
Locality Name (eg, city) [Caracas]:
Organization Name (eg, company) [Gomix Org]:
Organizational Unit Name (eg, section) []:Soporte
Common Name (eg, your name or your server's hostname) [cmartinez]:
Email Address [guillermo.gomez@gmail.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easyrsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'VE'
stateOrProvinceName   :PRINTABLE:'DC'
localityName          :PRINTABLE:'Caracas'
organizationName      :PRINTABLE:'Gomix Org'
organizationalUnitName:PRINTABLE:'Soporte'
commonName            :PRINTABLE:'cmartinez'
emailAddress          :IA5STRING:'guillermo.gomez@gmail.com'
Certificate is to be certified until Aug 20 00:01:09 2018 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

Configuración

En Fedora los archivos de configuración de muestra están en /usr/share/doc/openvpn-2.1/sample-config-files .

Configuración Servidor

Partiremos del archivo de configuración de muestra server.conf, y sólo mostraremos los cambios más importantes.

# cp /usr/share/doc/openvpn-2.1/sample-config-files/server.conf /etc/openvpn/

Ajuste las rutas que apuntan a los archivos de los certificados tanto de la autoridad como del servidor.

Customización por Cliente

Una de las preguntas típicas es como por ejemplo asignar direcciones IP fijas a nuestros clientes VPN con la intención de implementar políticas de filtrado de paquetes para dichas conexiones, este tipo de requerimientos es fácilmente resoluble implementando configuraciones específicas por cliente, es decir, por certificado del cliente, veamos como.

La solución es crear un directorio dentro del directorio de configuración de OpenVPN y colocar allí la configuración por cliente. Asumamos que ese directorio se llama “dcc” de “Directorio de Configuraciones de Clientes”. Entonces necesita agregar la línea de configuración “client-config-dir dcc” a su archivo de configuración server.conf.

Agregue client-config-dir dcc a su configuración de servidor (server.conf)

Dentro de dcc usted crea un archivo por cada cliente que desea configurar y le llama exactamente de acuerdo al common name del certificado del cliente. En estos archivos puede utilizar declaraciones ordinarias de OpenVPN. Para asignar direcciónes ip fijas usted usaría entonces “ipconfig-push 10.8.0.X 10.8.0.0″ si utiliza la subred sugerida “10.8.0.0″.

Configuración Cliente

Linux

Opción 1: NetworkManager-openvpn

yum install NetworkManager-openvpn

Mac

Ver http://code.google.com/p/tunnelblick/

Windows

Descargas
Instalación TAP

El paquete de OpenVPN incorpora un utilitario para agregar las interfases TAP. *Gran Duda, ¿viene en el paquete de OpenVPN o en el paquete de OpenVPN-GUI?*

 Menú: Windows - Todos Los Programas - OpenVPN - Add a new TAP

Una vez agregada la interfase TAP, vaya al control panel y ajuste el nombre de la interfase a algo que le sea más fácil de manejar, como _vpn_. En el ejemplo abajo hemos usado vpn2.

Imagen:Openvpn-cliente-tap-interfase.png

Archivo de Configuración

Completar/Comentar

client
dev tun
dev-node vpn2
proto udp
remote servidor.neotechgw.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
cipher AES-128-CBC
route-method exe
route-delay 2
mute-replay-warnings
ca ca.crt
cert gomix.crt
key gomix.key
comp-lzo
verb 4
pull
tls-client
Llaves y Certificados

Como se mencionó arriba, los archivos .crt y .key deben ser colocados en el lugar adecuado. De cómo se generan, no es relevante en este momento para el usuario final, lo mejor simplemente es solicitarlos al admin de la red. Nuevamente la localización de estos archivos es Archivos de Programas/OpenVPN/Config/.

Imagen:Openvpn-cliente-dir-config.png

Vista

http://www.personalvpn.org/openvpn_vista.htm

La solución de los problemas con OpenVPN pueden ser resueltos siguiendo los pasos siguientes.

  1. Use OpenVPN version 2.1 o superior.
  2. Cuando instale OpenVPN en Vista siempre haga clic derecho sobre el archivo y use la opción "install as admin".
  3. Siempre haga clic derecho y ejecute OpenVPN como administrador.