averainy's Blog

averainy

11 Oct 2024

使用wg-easy管理Wireguard

最近为了开源节流,准备更换宽带运营商,大概率将不会有公网ip,所以在阿里云买了一台云服务器。为了连到家里得nas,决定选Wireguard。

docker-compose.yml配置如下:

services:
  wg-easy:
    image: weejewel/wg-easy
    container_name: wg-easy
    environment:
      - WG_HOST=<域名或IP>
      - PASSWORD=<密码>
      - WG_DEFAULT_ADDRESS=10.0.1.x
      - WG_DEFAULT_DNS=114.114.114.114
      - WG_ALLOWED_IPS=10.0.1.0/24
      - WG_PERSISTENT_KEEPALIVE=25
    volumes:
      - /home/docker/wireguard/wireguard:/etc/wireguard
    ports:
      - "51820:51820/udp"
      - "51821:51821/tcp"
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv4.ip_forward=1
    restart: unless-stopped

docker compose up -d运行起来之后,访问<域名或IP>:51821 即可进行客户端配置文件得管理。