Create WireGuard VPN server with Docker / 用 docker 建立 wireguard vpn , simple/sample/example/config


到 linuxserver.io 搜尋 wireguard

https://fleet.linuxserver.io

docker hub https://hub.docker.com/r/linuxserver/wireguard

—> git hub https://github.com/linuxserver/docker-wireguard

–> more explain https://youtu.be/GZRTnP4lyuo

 

— config file sample

version: "2.1"
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard:latest
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Taipei
      - SERVERURL=auto
      - SERVERPORT=51820 #optional
      - PEERS=5 #optional
      - PEERDNS=8.8.8.8 #optional
      - INTERNAL_SUBNET=10.13.13.0 #optional
      - ALLOWEDIPS=0.0.0.0/0 #optional
      - LOG_CONFS=true #optional
    volumes:
      - ./config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: always

 

啟動 docker-compose up -d

 

會建立 config 目錄, config 目錄下有

 

Screen Shot 2022 08 11 at 9 52 22 AM

 

 

各 peer 的 config file

Screen Shot 2022 08 11 at 10 32 12 AM

 

在 mac 裝好 wireguard client

把其中之一的 peerX.conf 貼到 mac

cat > peer1.conf

….

 

在 wireguard client 中 import 進來

Screen Shot 2022 08 11 at 10 43 40 AM

 

 

wireguard 也提供掃描 QR code 設定方式, 例如: