Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Crear VPN con Docker usando Wireward

Tiempo de lectura: 2 minutos

Hoy vamos a ver cómo crear un VPN de forma rápida usando Docker Compose.

Suponiendo que tenemos ya instalado Docker en nuestro sistema. Lo primero que vamos a hacer es crear el archivo docker-compose.yml con el siguiente contenido:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wireguard_easy:
image: weejewel/wg-easy
container_name: wireguard_easy
restart: unless-stopped
volumes:
- ./config/wireguard:/etc/wireguard
ports:
- "51820:51820/udp"
- "54323:51821/tcp"
environment:
- WG_HOST=direccion_host/ip_publica
# Optional:
- PASSWORD=passwrod123
#- WG_PORT=51820
# - WG_DEFAULT_ADDRESS=10.8.0.x
- WG_DEFAULT_DNS=1.1.1.1
# - WG_MTU=1420
# - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
networks:
- docker-network
wireguard_easy: image: weejewel/wg-easy container_name: wireguard_easy restart: unless-stopped volumes: - ./config/wireguard:/etc/wireguard ports: - "51820:51820/udp" - "54323:51821/tcp" environment: - WG_HOST=direccion_host/ip_publica # Optional: - PASSWORD=passwrod123 #- WG_PORT=51820 # - WG_DEFAULT_ADDRESS=10.8.0.x - WG_DEFAULT_DNS=1.1.1.1 # - WG_MTU=1420 # - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24 cap_add: - NET_ADMIN - SYS_MODULE sysctls: - net.ipv4.ip_forward=1 - net.ipv4.conf.all.src_valid_mark=1 networks: - docker-network
wireguard_easy:
    image: weejewel/wg-easy
    container_name: wireguard_easy
    restart: unless-stopped
    volumes:
      - ./config/wireguard:/etc/wireguard
    ports:
      - "51820:51820/udp"
      - "54323:51821/tcp"
    environment:
      - WG_HOST=direccion_host/ip_publica
      # Optional:
      - PASSWORD=passwrod123
      #- WG_PORT=51820
      # - WG_DEFAULT_ADDRESS=10.8.0.x
      - WG_DEFAULT_DNS=1.1.1.1
      # - WG_MTU=1420
      # - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
    networks:
      - docker-network

Utilizamos la imagen de weejewel/wg-easy

Primero consultamos nuestra IP pública por ejemplo usando esta web https://www.cual-es-mi-ip.net/

Una vez tenemos nuestra IP pública, tendremos que crear un Dominio y vincularlo a nuestra IP. Una vez generado, añadimos en el apartado de WG_HOST el host indicado o la IP pública de nuestra máquina.

También es recomendable establecer una contraseña: PASSWORD=passwrod123

Una vez relleno todo, lo lanzamos utilizando docker compose up -d y accedemos a localhost:54323

Al acceder a la dirección, nos pedirá el password establecido anteriormente:

Una vez iniciado, creamos un nuevo cliente:

Introducimos su nombre.

Y podremos obtener su QR para escanearlo con la APP de Wireward, desactivarlo, borrarlo o descargar la configuración.

La app podrás descargarla aquí: https://www.wireguard.com/install/

Recuerda que para poder conectar a tu VPN tendrás que abrir el puerto 51820 de tu router.

0

Deja un comentario