使用 Wireguard 安装和配置您自己的 VPN。



我们将安装 Wireguard VPN 实时连接家用计算机和设备,以便从服务器的公共 IP 访问互联网。 1- 我们从 TOR 访问 vps 2- 我们在 Linux 服务器上安装 Wireguard 以创建 VPN 网络 3- 我们将看到如何连接 Ubuntu 20.04 客户端 4- 我们将看到如何连接 Windows 10 客户端 5- 我们验证从具有“ping”的客户端到已建立的 IP 私有。 6- 我们使用所有设备通过 VPS 服务器的公共 IP 上网 命令安装和配置 VPN 注意:文本框不接受“大于”符号。 $ su (我们进入root用户) # apt install wireguard (我们在Client和Server安装Wireguard) # cd /etc/wireguard / (我们访问应用程序目录) # umask 077 (我们建立目录和文件的权限) # wg基因 | tee server_private.key | wg pubkey “大于” server_public.key(我们为服务器创建密钥)# wg genkey | tee local_private.key | wg pubkey “greater than” local_public.key (我们为客户端创建密钥) # chmod 600 -R ../wireguard/ (我们为了安全而改变权限) # touch wg0.conf (我们创建配置文件) # cat server_private.key “greater than” “greater than” wg0.conf(我们在文件#nano wg0中引入key(我们编辑配置文件) wg0的内容 专用服务器或VPS的文件

[Interface]
地址 = 30.0.0.1/24 PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE ListenPort = 51820 PrivateKey = Aquí va la clave privada del servidor VPS
[Peer]
PublicKey = 这里是客户端的公钥(我们家的电脑) AllowedIPs = 30.0.0.2/32 Endpoint = xx.xx.xx.xx: 5760(xx是VPS服务器的公网ip) 客户端wg0文件的内容:
[Interface]
地址 = 30.0.0.2/24 PrivateKey = 本机(客户端)的私钥
[Peer]
PublicKey = 这里是 VPS 服务器的公钥 AllowedIPs = 0.0.0.0/0 EndPoint = xx.xx.xx.xx: 51820(vps 服务器的 ip 后跟:端口) PersistentKeepAlive = 25 命令安装,启用,挂载和卸载 VPN systemctl enable wg-quick @ wg0(启动时安装启动) systemctl disable wg-quick @ wg0(卸载) systemctl start wg-quick @ wg0(启用 VPN) systemctl stop wg-quick @ wg0(禁用 VPN) ) systemctl status wg-quick @ wg0 (查看状态) wg-quick up wg0 (激活VPN) wg-quick down wg0 (停用) # sysctl -w net.ipv4.ip_forward = 1 (我们在服务器能够通过其公共 IP 传递家庭设备的互联网流量)由于复杂性,它是一个中长视频。 任何问题我都会在评论中回答。 谢谢! .