Background
WireGuard
是一种新型的VPN协议,它通过在内核层运行,提供高效、安全、简单和现代的VPN解决方案。wg-easy
是一个专为简化 WireGuard VPN配置和管理而设计的工具,提供了界面化的管理,进一步降低WireGuard 的使用门槛,让用户无需深入了解其底层工作原理即可轻松部署和管理 WireGuard VPN。firefly
是最简单易用的轻量级、高性能WireGuard服务端软件,可广泛用于异地组网、远程办公、内网穿透等场景。支持自动申请免费SSL证书并续期。
1.各项目信息
# WireGuard 项目地址
https://github.com/WireGuard
# WireGuard 项目官网
https://www.wireguard.com/
# wg-easy github地址
https://github.com/wg-easy/wg-easy
# firefly github地址
https://github.com/Safe3/firefly
2.wg-easy安装
- run
docker run -d \
--name=wg-easy \
-e LANG=chs \
-e WG_HOST=110.110.110.110 \ # 公网IP
-e PASSWORD=123456 \ # web界面登录密码
-e PORT=51821 \
-e WG_PORT=51820 \
-v /usr/local/wg-easy/data:/etc/wireguard \
-p 51820:51820/udp \
-p 51821:51821/tcp \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
--sysctl="net.ipv4.ip_forward=1" \
--restart unless-stopped \
ghcr.io/wg-easy/wg-easy
docker-compose.yml
version: "3.5"
services:
wg-easy:
environment:
- LANG=chs
- WG_HOST=110.110.110.110
- PASSWORD=123456
- PORT=51821
- WG_PORT=51820
- WG_DEFAULT_ADDRESS=10.0.0.x
- WG_DEFAULT_DNS=114.114.114.114
- WG_MTU=1420
- WG_ALLOWED_IPS=10.0.0.0/24
- WG_PERSISTENT_KEEPALIVE=25
- UI_TRAFFIC_STATS=true
- UI_CHART_TYPE=2
image: ghcr.io/wg-easy/wg-easy
container_name: wg-easy
volumes:
- /usr/local/wg-easy/data:/etc/wireguard
ports:
- "51820:51820/udp"
- "51821:51821/tcp"
restart: unless-stopped
cap_add:
- NET_ADMIN
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
3.firefly安装
docker-compose.yml
version: '3'
services:
firefly:
image: "uusec/firefly:latest"
container_name: firefly
devices:
- /dev/net/tun
network_mode: host
volumes:
- /lib/modules:/lib/modules
- /etc/firefly:/firefly/conf
cap_add:
- NET_ADMIN
- SYS_MODULE
restart: unless-stopped
environment:
- TZ=Asia/Shanghai
- FIREFLY_DEVICE=eth0
- FIREFLY_PASSWORD=firefly
- FIREFLY_AUTO_SSL=false
- FIREFLY_PORT=50121
4.启动异常解决Cannot find device "wg0"
$ wg-quick down wg0
$ wg-quick up wg0
Error: WireGuard exited with the error: Cannot find device "wg0"
This usually means that your host's kernel does not support WireGuard!
at /app/lib/WireGuard.js:64:19
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /app/lib/WireGuard.js:62:9
解决方法请参考另一篇文档【Linux内核升级】