Article directory
Prerequisites
WireGuard installation (Wg-easy)
docker common commands
VPS安装Wireguard的先决条件
Devices with public IP addresses/IPV6 are also available (this note uses a VPS with Ubuntu18.04 operating system as an example)
VPS enable SSH
Install Docker on VPS
Installation steps of VPS Wireguard
1. Docker installation
sudo apt install docker.io docker-compose
sudo service docker start
whoami
sudo usermod -aG docker {ubuntu} //添加用户进docker组
exec su - $USER //输入密码2. Create Wg-easy password and key
docker run -it ghcr.io/wg-easy/wg-easy wgpw {你的密码}
PASSWORD_HASH='$2a$12$NJOIUwURc7qX4XnihBNKqOTSqKVxGJahAmwg6FUuboLvxzapBCYHK' //{你的密码}
//系统自动开始拉取镜像并返回密码密匙
//复制保存好密匙3. Run wg-easy docker image
docker run --detach \
--name wg-easy \
--env LANG=en \
--env WG_HOST={你的服务器地址} \
--env PASSWORD_HASH='{步骤2中获取的密码密匙}' \
--env PORT=51821 \
--env WG_PORT=65534 \
--volume ~/.wg-easy:/etc/wireguard \
--publish 65534:65534/udp \
--publish 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 ps //查看容器 运行状态 以及列表
docker stop wg-easy //停止容器
docker start wg-easy // 启动容器
docker rm wg-easy //删除容器4. Log in to wg-easy and add peer
When the container is running normally, you can access the server address in the browser with the port.
For example: http://{服务器地址}:51821
For password, please enter the password you set in step 2 to add it.
The configuration information of the peer is in the downloaded cnf file. Use notepad++ to view it.
Docker common commands
docker ps //查看容器 运行状态 以及列表
docker stop wg-easy //停止容器
docker start wg-easy // 启动容器
docker rm wg-easy //删除容器