Ubuntu 24快速搭建wireguard

curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
sudo ./wireguard-install.sh

一键搭建脚本  一路ok  即可

下载 wireguard 软件

https://www.wireguard.com/install/
建议选择msi
https://download.wireguard.com/windows-client/
找到
wireguard-installer.exe 下载

配置  客户端

/home/ubuntu/wg0-client-xiao2.conf

创建新用户  选择1

sudo ./wireguard-install.sh 
Welcome to WireGuard-install!
The git repository is available at: https://github.com/angristan/wireguard-install

It looks like WireGuard is already installed.

What do you want to do?
   1) Add a new user
   2) List all users
   3) Revoke existing user
   4) Uninstall WireGuard
   5) Exit
Select an option [1-5]: 

填入名字



配置 国内  AllowedIPs
AllowedIPs = 0.0.0.0/8, 1.1.1.1/32, 2.0.0.0/8, 4.0.0.0/8, 5.0.0.0/8, 6.0.0.0/8, 8.8.8.8/32, 9.0.0.0/8, 12.0.0.0/8, 13.0.0.0/8, 15.0.0.0/8, 16.0.0.0/8, 17.0.0.0/8, 18.0.0.0/8, 20.0.0.0/8, 23.0.0.0/8, 24.0.0.0/8, 26.0.0.0/8, 28.0.0.0/8, 31.13.0.0/16, 32.0.0.0/8, 37.0.0.0/8, 38.0.0.0/8, 40.0.0.0/8, 41.0.0.0/8, 44.0.0.0/8, 46.0.0.0/8, 48.0.0.0/8, 50.0.0.0/8, 52.0.0.0/8, 53.0.0.0/8, 54.0.0.0/8, 55.0.0.0/8, 56.0.0.0/8, 57.0.0.0/8, 62.0.0.0/8, 63.0.0.0/8, 64.0.0.0/8, 65.0.0.0/8, 67.0.0.0/8, 68.0.0.0/8, 69.0.0.0/8, 70.0.0.0/8, 71.0.0.0/8, 72.0.0.0/8, 73.0.0.0/8, 74.0.0.0/8, 76.0.0.0/8, 80.0.0.0/8, 81.0.0.0/8, 82.0.0.0/8, 83.0.0.0/8, 84.0.0.0/8, 86.0.0.0/8, 87.0.0.0/8, 88.0.0.0/8, 92.0.0.0/8, 93.0.0.0/8, 94.0.0.0/8, 95.0.0.0/8, 96.0.0.0/8, 100.0.0.0/8, 102.0.0.0/8, 104.0.0.0/8, 105.0.0.0/8, 107.0.0.0/8, 108.0.0.0/8, 109.0.0.0/8, 128.0.0.0/8, 129.0.0.0/8, 130.0.0.0/8, 131.0.0.0/8, 132.0.0.0/8, 133.0.0.0/8, 134.0.0.0/8, 135.0.0.0/8, 136.0.0.0/8, 137.0.0.0/8, 138.0.0.0/8, 139.0.0.0/8, 141.0.0.0/8, 142.0.0.0/8, 143.0.0.0/8, 144.0.0.0/8, 145.0.0.0/8, 146.0.0.0/8, 147.0.0.0/8, 148.0.0.0/8, 149.0.0.0/8, 150.0.0.0/8, 151.0.0.0/8, 152.0.0.0/8, 153.0.0.0/8, 154.0.0.0/8, 155.0.0.0/8, 156.0.0.0/8, 157.0.0.0/8, 158.0.0.0/8, 159.0.0.0/8, 160.0.0.0/8, 161.0.0.0/8, 162.0.0.0/8, 163.0.0.0/8, 164.0.0.0/8, 165.0.0.0/8, 166.0.0.0/8, 167.0.0.0/8, 168.0.0.0/8, 169.0.0.0/8, 170.0.0.0/8, 171.0.0.0/8, 172.0.0.0/8, 173.0.0.0/8, 174.0.0.0/8, 175.0.0.0/8, 176.0.0.0/8, 180.0.0.0/8, 181.0.0.0/8, 182.0.0.0/8, 184.0.0.0/8, 185.60.0.0/16, 188.0.0.0/8, 189.0.0.0/8, 190.0.0.0/8, 193.0.0.0/8, 194.0.0.0/8, 195.0.0.0/8, 196.0.0.0/8, 198.0.0.0/8, 199.0.0.0/8, 200.0.0.0/8, 204.0.0.0/8, 205.0.0.0/8, 206.0.0.0/8, 208.0.0.0/8, 212.0.0.0/8, 213.0.0.0/8, 214.0.0.0/8, 216.0.0.0/8, 224.0.0.0/8


注意 Endpoint = 111.222.111.222:62986
写入公网ip 否则无法上网


代理走国内配置dns

下载  AdGuardHome_windows_amd64.zip
github地址
https://github.com/AdguardTeam/AdGuardHome/releases

解压后双击打开  AdGuardHome.exe

本地地址
http://127.0.0.1:3000   后面设置完 可能改为 http://127.0.0.1:80  了



设置监听地址  选择本地lookback  地址  
DNS server:
127.0.0.1:53


设置  -->   dns设置

上游dns设置
国外使用8.8.8.8  其他默认使用国内的

[/openai.com/]8.8.8.8
[/chatgpt.com/]8.8.8.8
[/google.com/]8.8.8.8
[/cursor.com/]8.8.8.8
[/facebook.com/]8.8.8.8
[/youtube.com/]8.8.8.8
[/google.com/]8.8.8.8
[/gmail.com/]8.8.8.8
[/docs.google.com/]8.8.8.8
[/drive.google.com/]8.8.8.8
[/outlook.com/]8.8.8.8
[/office.com/]8.8.8.8
[/microsoft.com/]8.8.8.8
[/live.com/]8.8.8.8
[/fb.com/]8.8.8.8
[/twitter.com/]8.8.8.8
[/instagram.com/]8.8.8.8
[/linkedin.com/]8.8.8.8
[/tiktok.com/]8.8.8.8
[/netflix.com/]8.8.8.8
[/spotify.com/]8.8.8.8
[/soundcloud.com/]8.8.8.8
[/vimeo.com/]8.8.8.8
[/github.com/]8.8.8.8
[/gitlab.com/]8.8.8.8
[/bitbucket.org/]8.8.8.8
[/stackoverflow.com/]8.8.8.8
[/npmjs.com/]8.8.8.8
[/docker.com/]8.8.8.8
[/nodejs.org/]8.8.8.8
[/python.org/]8.8.8.8
[/openai.com/]8.8.8.8
[/chat.openai.com/]8.8.8.8
[/aws.amazon.com/]8.8.8.8
[/amazon.com/]8.8.8.8
[/googleapis.com/]8.8.8.8
[/cloudflare.com/]8.8.8.8
[/cloud.google.com/]8.8.8.8
[/adobe.com/]8.8.8.8
[/paypal.com/]8.8.8.8
[/ebay.com/]8.8.8.8
211.140.13.188
223.5.5.5

选择最快的ip地址
应用

DNS 缓存配置
启用
覆盖最小 TTL 值
600
覆盖最大 TTL 值
86400
保存



然后配置  wireguard  
DNS = 127.0.0.1


测试是否成功  这样就对了

nslookup google.com
服务器:  activate.navicat.com
Address:  127.0.0.1

非权威应答:
名称:    google.com
Addresses:  2404:6800:4012:8::200e
          142.251.218.174



设置AdGuardHome  自启动  为服务程序
在安装目录右键  打开终端 powershell
.\AdGuardHome.exe -s install   安装服务  设置为自动
.\AdGuardHome.exe -s start   启动服务