metaligh/amneziawg

By metaligh

Updated almost 2 years ago

Amnezia WireGuard is a simple, secure, and high-performance VPN solution based on WireGuard.

Image
Networking
Security
12

50K+

metaligh/amneziawg repository overview

Icon

Aéza VPS Hosting

Aéza Logo

Launch your projects with Aéza's ultra-affordable VPS from just €1!
Choose from multiple global locations and enjoy instant setup in under 5 minutes.
Powered by AMD processors and NVMe SSDs with AntiDDoS protection.
Start now at my-aeza.net! 20% CASHBACK

Amnezia WireGuard VPN Server

(fork of WireGuard) (https://docs.amnezia.org/documentation/amnezia-wg/)

This Docker image allows you to quickly set up and run a WireGuard server in a containerized environment, offering an easy-to-use, lightweight VPN with enhanced privacy and security. It is not recognized by DPI (Deep Packet Inspection) analysis systems, making it resistant to blocking.

Features:

  • Lightweight and Fast: Built on WireGuard, known for its minimal codebase, fast speeds, and low overhead.
  • Secure: WireGuard uses state-of-the-art cryptography to provide strong encryption and secure communications.
  • Easy Setup: Quickly deploy a VPN server with minimal configuration.
  • Cross-Platform: Compatible with various clients, including Linux, Windows, macOS, Android, and iOS.
  • Automated Configuration: Automatically configure WireGuard keys and settings for ease of use.

Usage:

Pull the Docker Image:
docker pull metaligh/amneziawg
Run the Container:
docker run -d --name amnezia_container --cap-add NET_ADMIN --device /dev/net/tun -p 51820:51820/udp metaligh/amneziawg
Access Your VPN:

Configure your clients using the generated configuration or QR codes provided by the container.

You can configure:

  • New parameters: Jc, Jmin, Jmax, S1, S2, H1, H2, H3, H4 (vpn_params.cfg)
  • IP: IP address of your Amnezia WireGuard Server (AWG). (serverip.cfg)
  • DNS: Default is Google DNS Servers. (serverip.cfg)
  • AWG_PORT: Specify the WireGuard port (default is 51820). (serverip.cfg)

Volume Configuration:

  • /etc/amnezia/amneziawg: Mount this directory to store the script, configuration, and keys before running the container:

Here are two ways:

1) You need to manually copy these files from https://github.com/metaligh/amneziawg/blob/main/amneziawg.tar.gz File: amneziawg.tar.gz

Unpack amneziawg.tar.gz to /opt/amneziawg/

mkdir -p /opt/amneziawg && tar -xzf amneziawg.tar.gz -C /opt/amneziawg/
2) OR copy it from container:
docker cp amnezia_container:/etc/amnezia/amneziawg/ /opt/

You can generate keys from the host system:

In this case also copy awg from container to host first -

docker cp amnezia_container:/usr/bin/awg /usr/bin/

The container includes all necessary tools to generate or regenerate keys and add or remove VPN clients.

VPN Configuration:

docker exec -it amnezia_container /bin/bash

By accessing the running Docker container, you can follow this process:

Check Available Files:
cat ./readme
ls -la
Server Files List:

awgstart awguser readme serverip.cfg vpn_params.cfg

1) Modify "serverip.cfg":

  • This file should include:
    • 1.1) Your server IP for client connections.
    • 1.2) Server DNS names.
    • 1.3) UDP server port for AWG. To edit files:
nano ./serverip.cfg

"vpn_params.cfg" contains additional Amnezia WireGuard parameters.

nano ./vpn_params.cfg

2) Generate the Initial User:

Run the following command to generate the primary user configuration and QR code for the first connection:

awguser

3) Start the Server:

awgstart

4) To add or remove users:

Run awguser again, then after verifying the configuration, run awgstart to apply changes. This will generate a QR code for your convenience.

5) If you modify any .cfg files:

You must regenerate all .conf files. This can be done using the awguser command.

Important:

Always run the awgstart command after making any changes to ensure they take effect.

6) Exit the Console:

exit

If you have mounted a volume on your host system, simply restart the container after updating the configuration files by running:

docker restart amnezia_container

Using Docker Compose

If you want to use Docker Compose, create a file named docker-compose.yaml with the following content:

services:
  amneziawgml:
    image: metaligh/amneziawg:latest
    container_name: amnezia_container
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
#    volumes:
#      - /opt/amneziawg:/etc/amnezia:rw
    ports:
      - "51820:51820/udp"
    restart: unless-stopped

After creating the file, run the following command to start the service:

docker compose up -d

Then proceed with the configuration above.↑

Additional information:

Don't forget to configure routing from your interface for your VPN server to access the Internet on host server:

sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward = 1" > /etc/sysctl.conf
sudo sysctl -p

Just a variant for iptables, where eth0 is your interface to get to the internet:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.200.0/32 -j MASQUERADE
After that, you can use any AmneziaWG client for your devices. Download them from the project page listed at the beginning.

Tag summary

Content type

Image

Digest

sha256:b9c97c8c7

Size

35.1 MB

Last updated

almost 2 years ago

docker pull metaligh/amneziawg