脚本安装地址:
https://github.com/angristan/wireguard-install
curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.sh
运行之后:
IPv4 or IPv6 public address:(这里填写服务器的外网ip地址)
Public interface: (eth0)绑定的网卡
WireGuard interface name: wg0(wg虚拟网卡,不用改)
Server WireGuard IPv4: 10.66.66.1(wg组网的ip4,不用改)
Server WireGuard IPv6: fd42:42:42::1(wg组网的ip6,不用改)
Server WireGuard port [1-65535]: 62313(wg使用端口,可改了,然后在服务器防火墙添加进去放行这个端口,注意添加UDP协议)
First DNS resolver to use for the clients: 1.1.1.1(DNS,或改成8.8.8.8)
Second DNS resolver to use for the clients (optional): 1.0.0.1(备用DNS)
WireGuard uses a parameter called AllowedIPs to determine what is routed over the VPN.
Allowed IPs list for generated clients (leave default to route everything): 0.0.0.0/0,::/0 (允许客户端ip,不用改)
Okay, that was all I needed. We are ready to setup your WireGuard server now.
You will be able to generate a client at the end of the installation.
Press any key to continue…
开始,随便取个名称:
The client name must consist of alphanumeric character(s). It may also include underscores or dashes and can’t exceed 15 chars.
Client name: jb
Client WireGuard IPv4: 10.66.66.2
Client WireGuard IPv6: fd42:42:42::2
然后会生成一个配置文件和二维码:
Here is your client config file as a QR Code:
。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。。
Your client config file is in /root/wg0-client-jb.conf
If you want to add more clients, you simply need to run this script another time!
WireGuard is running.
You can check the status of WireGuard with: systemctl status wg-quick@wg0
If you don’t have internet connectivity from your client, try to reboot the server.
在客户端下载个工具软件导入刚才的conf文件,或者扫码就行:
https://www.wireguard.com/install/
