Requirements: Based on WireGuard, multiple remote devices can be formed into a local area network, and each device can access each other, for example, a computer from Shanghai Mobile and a computer from Shandong Unicom can access each other, as shown in the figure below:
WireGuard is an extremely simple yet fast and modern VPN with state-of-the-art encryption. Its goal is to be faster, simpler, leaner, and more useful than IPsec while avoiding headaches. Its performance is much higher than OpenVPN. WireGuard is designed to be a general-purpose VPN that runs on embedded interfaces and supercomputers, making it suitable for many different situations. Originally released for the Linux kernel, it is now cross-platform (Windows, macOS, BSD, iOS, Android) and widely deployable. It's currently in heavy development, but it's probably already considered the most secure, easy-to-use, and simplest VPN solution in the industry.
Official Website:The hyperlink login is visible. Source:The hyperlink login is visible.
Docker WireGuard Images:The hyperlink login is visible. Docker WireGuard source code:The hyperlink login is visible.
This article is based on Docker to run WireGuard, and when starting the wg-easy container with CentOS 7, the error is as follows:
Error: WireGuard exited with the error: Cannot find device "wg0" This usually means that your host's kernel does not support WireGuard! So, replace an Ubuntu 20.04 system and install the docker service with the following command:
An example of running a WireGuard container is as follows:
$ docker run -d \ --name=wg-easy \ -e WG_HOST=YOUR_SERVER_IP \ -e PASSWORD=YOUR_ADMIN_PASSWORD \ -v ~/.wg-easy:/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 \ weejewel/wg-easy You need to modify and add environment variables: WG_HOST, PASSWORD, WG_DEFAULT_DNS, WG_PERSISTENT_KEEPALIVE, and the modified command is as follows:
The Cloud Server Firewall security group needs to be released:UDP/51820,TCP/51821Port.
Then access it through your browser:http://ip:51821/As shown below:
Create two new clients, and then download the configuration file, Home1 corresponds to Shanghai Mobile, and Home2 corresponds to Shandong Unicom, as shown in the figure below:
Shanghai Mobile and Shandong Unicom are both Windows devices, you need to download the Windows installer, download address:The hyperlink login is visible.
Tourists, if you want to see the hidden content of this post, please Reply
Example profile:
After Shanghai Mobile and Shandong Unicom download and install them, import the WireGuard configuration files respectively, as shown in the figure below:
Another computer imports another configuration file and connects. (omitted)
Test accessing the web service on the 10.8.0.3 computer from 10.8.0.2 as shown in the following figure:
(End)
|