首先安装docker
curl -fsSL https://get.docker.com | bash
配置sysctl /etc/sysctl.conf添加ipv4 ipv6转发
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
保持后执行
sysctl -p
Docker Compse配置文件如下:
volumes:
etc_wireguard:
services:
wg-easy:
environment:
# Change Language:
# (Supports: en, ua, ru, tr, no, pl, fr, de, ca, es, ko, vi, nl, is, pt, chs, cht, it, th, hi, ja, si)
- LANG=chs
# ⚠️ Required:
# Change this to your host's public address
# ipv4或者ipv6 v6要用[2409:8c54:1011:b::49a]
- WG_HOST=
#https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md
- PASSWORD_HASH=$$2a$$12$$wSlftiD.YXeo5OmddioBvODMyTYon5GbKWFfPEXjeWrddk7.8tXmA
#web port 可自定义
- PORT=55558
# connect port 可自定义
- WG_PORT=55557
- WG_DEFAULT_ADDRESS=192.168.200.0
- WG_DEFAULT_DNS=1.1.1.1
- WG_MTU=1420
- WG_ALLOWED_IPS=192.168.200.0/24
- WG_PERSISTENT_KEEPALIVE=25
- UI_TRAFFIC_STATS=true
- UI_CHART_TYPE=1 # (0 Charts disabled, 1 # Line chart, 2 # Area chart, 3 # Bar chart)
#- WG_ENABLE_ONE_TIME_LINKS=true
- UI_ENABLE_SORT_CLIENTS=true
- WG_ENABLE_EXPIRES_TIME=true
# - ENABLE_PROMETHEUS_METRICS=false
image: ghcr.io/wg-easy/wg-easy
container_name: wg-easy
volumes:
- .:/etc/wireguard
ports:
- "55557:55557/udp"
- "55558:55558/tcp"
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv6.conf.all.forwarding=1