Cómo instalar y configurar OpenVPN

Imagen de Epe

OpenVPN es una implementacion de VPN SSL la cual usa las extensiones OSI layer 2 ó 3 para asegurar redes la cual usa los protocolos SSL/TLS, soporta diferentes medios de autenticacion como certificados, smart cards, y/o usuarios/contraseñas, y permite politicas de control de acceso para usaurios o grupos usando reglas de firewall aplicadas a las interfaces virtuales de la VPN. OpenVPN 2.0 permite multiples clientes conectar a un solo servidor (proceso) OpenVPN sobre un simple puerto TCP o UDP.

Para seguir este documento se requieren conocimientos basicos de redes TCP/IP como , direcciones IP, DNS, netmasks, subnets, IP routing, routers, interfaces de red, LANs, gateways, y reglas de firewall.
Formas de trabajo del OpenVPN

Aunque OpenVPN es muy sencillo de configurar e instalar, podemos dividir su forma de trabajo en 3 tipos:

1. [b]Host a Host[/b]: Es el método más simple, nos permite encriptar la comunicación entre dos PC las cuales deberán solamente tener conexión; es decir: ambas PC deben poderse enviar paquetes directamente ya sea porque estén conectadas en la misma red local, o porque ambas estén conectadas a la internet y sean alcanzables entre sí.
2. [b]Road Warrior[/b]: Es una de las formas más utilizadas y solicitadas por los estudiantes. Es el permitir que una máquina de alguien que esté fuera de nuestra red (de forma temporal o permanente) pueda comunicarse con el servidor OpenVPN de nuestra red y una vez autenticado pueda entrar a ver y acceder los recursos de nuestra red local. En verdad es un caso especial de la conexión Red a Red que a continuación mencionamos:
3. [b]Red a Red[/b]: Uno de los métodos más usados. Mediante ésta forma dos redes separadas en el espacio pueden comunicarse como si estuvieran unidas por un cable virtual (de ahi la V de VPN); la comunicación entre ambas redes viajará encriptada una vez salgan de los servidores de openvpn y hasta que lleguen a su otro extremo.

[b]Ventajas del uso de OpenVPN[/b]

OpenVPN es un sistema de creación y uso de vpn muy modesto y fácil de utilizar que nos permite implementar vpn que de otras formas sería muy molesto o dificultoso de realizar.

Las implementaciones IPSec, aunque supuestamente mejor elaboradas y soportadas por el kernel de linux, son muy difíciles de implementar en máquinas con Windows. En el caso de OpenVPN existen clientes y servidores tanto para linux como para windows y su implementación para redes o sistemas multiplataformas es muy sencilla de llevar a cabo.

[b]Instalación del OpenVPN[/b]

Instalar OpenVPN en nuestro linux CentOS es realmente fácil. Solamente debemos tener instalado el EPEL y emitir el comando:


yum install openvpn easy-rsa

Después de unos minutos, tendremos listo el paquete de OpenVPN

Una vez instalado, podemos proceder a la creación de las claves de encriptación en el servidor y cliente.

[b]Activando OpenVPN[/b]

Aunque [b]todavía no es el momento de activarlo[/b], cuando hayamos configurado el openvpn podemos activarlo en CentOS-6 o CentOS-5 con:

service openvpn start
chkconfig openvpn on

Con estos dos simples comandos podemos arrancar el openvpn en ambos extremos.

En caso de CentOS-7 o superior debe ser así:

systemctl -f enable \
openvpn@X.service
systemctl start \
openvpn@X.service

Donde X es el nombre del archivo de configuración. Por ejemplo si el archivo se llama client1.conf X será: client1
Si el archivo se llama server.conf, X será: server

Si necesitáramos reiniciarlo (para que lea de nuevo la configuración por ejemplo) podríamos hacerlo con:


service openvpn restart

Comentarios

Sugerencia

Veo que estas instalando todo a pata jeje, te recomiendo que configures tu centos para tener acceso a repositorios, te sugiero este repositorio es bueno a mi forma de ver, existen varios mas, http://dag.wieers.com. aqui en ecualug esta la manera de hacerlo, esto te permitira intsalar cualquier paquete que necesites por medio de yum asi evitaras los lios de las dependencia, lee aqui esat como hacerlo
http://www.ecualug.org/?q=2006/03/30/comos/como_usar_el_repositorio_de_dag_en_nuestro_centos
espèro haberte ayudado un poco.
Suerte y éxitos
Atte Christian

Hola

Hola, esta guia esta ok, lo unico que necesita es usar imagenes para mejorar la vista de la guia....

openvpn1

openvpn2

ecualug
______________________
!!!AdminRed_Debian!!!

ecualug
______________________
!!!AdminRed_Debian!!!

NO LOGRO VER LAS MAQUINAS DETRAS DEL SERVER

Imagen de Ojavir

Hola

Estoy instalando una VPN en un Suse 10, la cual ya esta configurada de manera que el cliente responde ping del servidor y viceversa

pero mi problema radica, en que no logro hacer que el cliente pueda ver las maquinas detras del servidor.

En mi caso, la red interna es 192.168.6.0/24 y la red VPN es 10.8.0.0/24

- He colocado la linea push "route 192.168.6.0 255.255.255.0" en el server.conf

- He realizado los comandos

iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A INPUT -i tap+ -j ACCEPT
iptables -A FORWARD -i tap+ -j ACCEPT
iptables -A INPUT -p udp --dport 1194 -j ACCEPT (El signo "+" debe ser reemplazado por un cero o es asi tal cual??

- Habilite el Ip forwarding con echo 1 > /proc/sys/net/ipv4/ip_forward

y aun asi no logro ver las maquinas detras del servidor, desde el cliente!!

Que puede estar pasando?

Adjunto mi server.conf
# Which local IP address should OpenVPN
# listen on? (optional)
local 190.24.145.171

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one. You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one. On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key). Each client
# and the server must have their own cert and
# key file. The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys. Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca ssl/ca.crt
cert server.crt
key server.key # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
# openssl dhparam -out dh1024.pem 1024
# Substitute 2048 for 1024 if you are using
# 2048 bit keys.
dh dh1024.pem

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 10.8.0.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file. If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface. Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0. Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients. Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
# Push routes to the client to allow it
# to reach other private subnets behind
# the server. Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
push "route 192.168.6.0 255.255.255.0"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
# iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN. This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
# ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients. There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
# group, and firewall the TUN/TAP interface
# for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
# modify the firewall in response to access
# from different clients. See man
# page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# the TUN/TAP interface to the internet in
# order for this to work properly).
# CAVEAT: May break client's network config if
# client's local DHCP server packets get routed
# through the tunnel. Solution: make sure
# client's local DHCP server is reachable via
# a more specific route than the default route
# of 0.0.0.0/0.0.0.0.
;push "redirect-gateway"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses. CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
;push "dhcp-option DNS 10.8.0.1"
;push "dhcp-option WINS 10.8.0.1"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names. This is recommended
# only for testing purposes. For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120
# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
# openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
;cipher BF-CBC # Blowfish (default)
;cipher AES-128-CBC # AES
;cipher DES-EDE3-CBC # Triple-DES

# Enable compression on the VPN link.
# If you enable it here, you must also
# enable it in the client config file.
comp-lzo

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
user nobody
group nobody

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it. Use one
# or the other (but not both).
;log openvpn.log
# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 4

# Silence repeating messages. At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

A que te refieres con "no

Imagen de jcyepez

A que te refieres con "no puedo ver los equipos tras el server"??

No los puedes ver por el explorador de Guin2 o no puedes hacerles un simple ping.

Si logras hacer ping, seguramente es por el tipo de interfaz que estás utilizando para la vpn, si no estoy mal la interfaz de tipo tun, no permite broadcast y por ello "no se pueden ver los equipos".

Verifica primero si puedes dar un simple ping a algún equipo dentro de la red.

Saludos

Juan Yépez
0993681879
Dj - Discomovil Quito

Hola, gracias por tu pronta

Imagen de Ojavir

Hola, gracias por tu pronta respuesta!!

Te cuento que si puedo realizar ping entre la maquina 10.8.0.1 (server vpn) y el otro extremo 10.8.0.x (cliente) pero el cliente no puede hacer ping a ninguna maquina detras del servidor.. me refiero a alguna maquina que haga parte de la red lan del servidor

Disculpas por el post tan largo.. solo queria evitar algun dato faltante al cortarlo

Saludos!!

DUDA_VPV_HOST_TO_HOST

Hola, soy nuevo tanto en este foro como en el tema de VPN con openvpv, me interesa la opcion de host to host, mi pregunta es la siguiente, la configracion de ese servidor que se menciona es un pc que pertenece a la red?
Le agradesco sus respuesta y mas informacion sobre este tema, gracias.

openvpn es gratis?

Estimados, hasta cuantos clientes puedo crear con el openvpn? tengo entendido que openvpn ya no es gratis para mas de 2 estaciones, es eso cierto? Gracias por su respuesta.

hola, configuré hace una

Imagen de Epe

hola, configuré hace una semana o dos openvpn para 30 clientes road warriors sin inconvenientes.

de dónde sacaste la información de que hay que pagar por él? no confundir libertad con gratuidad.

a propósito openvpn tiene un esquema de soporte y ventas de ciertos servicios, pero el openvpn que yo uso es la versión comunitaria, la que es "gratis"

Saludos
epe

EcuaLinux.com

+(593) 9 9924 6504

Servicios en Software Libre

Páginas