Loading...  使用docker compose安装wireguard-ui,创建docker-compose.yml文件 ``` version: "3" services: wireguard: image: linuxserver/wireguard:latest container_name: wireguard cap_add: - NET_ADMIN volumes: - ./config:/config environment: LANG: 'C.UTF-8' TZ: Asia/Shanghai #timezone ports: # port for wireguard-ui. this must be set here as the `wireguard-ui` container joins the network of this container and hasn't its own network over which it could publish the ports - "5000:5000" # port of the wireguard server - "51820:51820/udp" wireguard-ui: image: ngoduykhanh/wireguard-ui:latest container_name: wireguard-ui depends_on: - wireguard cap_add: - NET_ADMIN # use the network of the 'wireguard' service. this enables to show active clients in the status page network_mode: service:wireguard environment: - SENDGRID_API_KEY - EMAIL_FROM_ADDRESS - EMAIL_FROM_NAME - SESSION_SECRET - WGUI_USERNAME=admin - WGUI_PASSWORD=admin - WG_CONF_TEMPLATE - WGUI_MANAGE_START=true - WGUI_MANAGE_RESTART=true - TZ=Asia/Shanghai #timezone logging: driver: json-file options: max-size: 50m volumes: - ./db:/app/db - ./config:/etc/wireguard ``` 在同一目录下运行命令安装 ``` docker-compose pull docker-compose up -d ``` 放行5000/tcp和51820/udp端口 访问ip:5000来到ui界面,默认用户名和密码均为admin,记得修改 首先可以修改虚拟网段  添加客户端配置  ip范围要在刚刚设置的网段内,Allowed IPs设置为虚拟网段的范围。不要设置成0.0.0.0,因为我们需要配置虚拟局域网而不是VPN代理,而且设置成0.0.0.0后如果没有配置ip转发会导致连接上wireguard的客户端断网。 ## 客户端 ## Windows 下载软件https://www.wireguard.com/install/,选择Windows版本,软件自带中文,在下载服务端添加的客户端配置,是一个后缀为conf的文件,在软件里导入。 ) 导入后直接连接即可,配置十分简单。 ## Liunx 首先安装wireguard,部分系统可能已经自带了 ``` sudo apt install wireguard ``` 同样在服务端下载添加的客户端配置,放到/etc/wireguard中 注意一个客户端使用一个配置,不要同时使用 假设你下载得到的conf文件名为wg0,那么在linux上使用命令启动 ``` wg-quick up wg0 ``` 关闭命令是 ``` wg-quick down wg0 ``` 设置为开机自启是 ``` sudo systemctl enable wg-quick@wg0 ``` 连接上后可以输入命令,查看连接情况 ``` wg ``` 也可以查看路由表,确认是否添加上服务端配置的虚拟网段10.0.0.0/24 ``` ip route ``` # 其他操作系统 官方下载页面还有其他操作系统的软件下载,连接方法应该也是大同小异  Last modification:August 13, 2023 © Allow specification reprint Support Appreciate the author WeChat Like 0 如果觉得我的文章对你有用,请随意赞赏
One comment
真棒!