原创文章,转载请注明出处
https://qiedd.com/

准备工作

安装ArchLinux (Gitlab)

安装好 yay (Github)(你也可以选择配置好ArchLinuxCN源后直接安装yay)

安装需要的工具

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 安装依赖
yay -S wireguard-tools openresolv wgcf vim dnsutils linux-headers --needed
# 安装依赖 yay -S wireguard-tools openresolv wgcf vim dnsutils linux-headers --needed
# 安装依赖
yay -S wireguard-tools openresolv wgcf vim dnsutils linux-headers --needed

配置wgcf

在当前目录下

我们需要用wgcf成配置文件,用于wireguard连接节点,请勿删除!

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 生产一个WARP账户 (wgcf-account.toml)
wgcf register
# 生产配置文件 (wgcf-profile.conf)
wgcf generate
# 生产一个WARP账户 (wgcf-account.toml) wgcf register # 生产配置文件 (wgcf-profile.conf) wgcf generate
# 生产一个WARP账户 (wgcf-account.toml)
wgcf register

# 生产配置文件 (wgcf-profile.conf)
wgcf generate

编辑配置文件

我们现在只有IPV4,只需要增加一个IPV6即可,因此配置文件如下

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 编辑配置文件
vim wgcf-profile.conf
[Interface]
PrivateKey = 这里会自动生成
Address = 172.16.0.2/32
Address = 这里会自动生成
DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = ::/0
Endpoint = 162.159.192.1:2408
# 编辑配置文件 vim wgcf-profile.conf [Interface] PrivateKey = 这里会自动生成 Address = 172.16.0.2/32 Address = 这里会自动生成 DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844 MTU = 1280 [Peer] PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= AllowedIPs = ::/0 Endpoint = 162.159.192.1:2408
# 编辑配置文件
vim wgcf-profile.conf

[Interface]
PrivateKey = 这里会自动生成
Address = 172.16.0.2/32
Address = 这里会自动生成
DNS = 8.8.8.8,8.8.4.4,2001:4860:4860::8888,2001:4860:4860::8844
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = ::/0
Endpoint = 162.159.192.1:2408

注意!!!

请先解析 engage.cloudflareclient.com,将获取到的IPV4填入 “Endpoint”
我这边是 162.159.192.1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
root@Arch ~# nslookup engage.cloudflareclient.com
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: engage.cloudflareclient.com
Address: 162.159.192.1
Name: engage.cloudflareclient.com
Address: 2606:4700:d0::a29f:c001
root@Arch ~# nslookup engage.cloudflareclient.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: engage.cloudflareclient.com Address: 162.159.192.1 Name: engage.cloudflareclient.com Address: 2606:4700:d0::a29f:c001
root@Arch ~# nslookup engage.cloudflareclient.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   engage.cloudflareclient.com
Address: 162.159.192.1
Name:   engage.cloudflareclient.com
Address: 2606:4700:d0::a29f:c001

尝试启动Wireguard

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 复制配置文件到wireguard文件夹
cp wgcf-profile.conf /etc/wireguard/wgcf.conf
# 尝试启动 wireguard
wg-quick up wgcf
# 执行 ip a 后,就能看到此接口了
4: wgcf: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
link/none
inet 172.16.0.2/32 scope global wgcf
valid_lft forever preferred_lft forever
inet6 **************************************** scope global
valid_lft forever preferred_lft forever
# 复制配置文件到wireguard文件夹 cp wgcf-profile.conf /etc/wireguard/wgcf.conf # 尝试启动 wireguard wg-quick up wgcf # 执行 ip a 后,就能看到此接口了 4: wgcf: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 172.16.0.2/32 scope global wgcf valid_lft forever preferred_lft forever inet6 **************************************** scope global valid_lft forever preferred_lft forever
# 复制配置文件到wireguard文件夹
cp wgcf-profile.conf /etc/wireguard/wgcf.conf

# 尝试启动 wireguard
wg-quick up wgcf

# 执行 ip a 后,就能看到此接口了

4: wgcf: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none 
    inet 172.16.0.2/32 scope global wgcf
       valid_lft forever preferred_lft forever
    inet6 **************************************** scope global 
       valid_lft forever preferred_lft forever

现在,你可以尝试用 v6 ping google了

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
root@Arch ~# ping -6 google.com
PING google.com(lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e)) 56 data bytes
64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=1 ttl=121 time=2.00 ms
64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=2 ttl=121 time=1.89 ms
root@Arch ~# ping -6 google.com PING google.com(lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e)) 56 data bytes 64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=1 ttl=121 time=2.00 ms 64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=2 ttl=121 time=1.89 ms
root@Arch ~# ping -6 google.com
PING google.com(lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e)) 56 data bytes
64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=1 ttl=121 time=2.00 ms
64 bytes from lax28s01-in-x0e.1e100.net (2607:f8b0:4007:801::200e): icmp_seq=2 ttl=121 time=1.89 ms

不过Arch这边默认还是优先走v4,你可以设置一下V6的优先级(可选)

编辑文件 /etc/gai.conf,将 label 2002::/16 2 的注释删除

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#label ::1/128 0
#label ::/0 1
label 2002::/16 2
#label ::/96 3
#label ::ffff:0:0/96 4
#label fec0::/10 5
#label fc00::/7 6
#label 2001:0::/32 7
#label ::1/128 0 #label ::/0 1 label 2002::/16 2 #label ::/96 3 #label ::ffff:0:0/96 4 #label fec0::/10 5 #label fc00::/7 6 #label 2001:0::/32 7
#label ::1/128       0
#label ::/0          1
label 2002::/16     2
#label ::/96         3
#label ::ffff:0:0/96 4
#label fec0::/10     5
#label fc00::/7      6
#label 2001:0::/32   7

不过毕竟v6还是走了层隧道,不是很推荐优先v6,除非你有特殊需求吧

收尾

现在只是临时启动wireguard,接下来让systemd来接管启动吧

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 关闭wgcf接口
wg-quick down wgcf
# 加入开机启动
systemctl start wg-quick@wgcf
systemctl enable wg-quick@wgcf
# 关闭wgcf接口 wg-quick down wgcf # 加入开机启动 systemctl start wg-quick@wgcf systemctl enable wg-quick@wgcf
# 关闭wgcf接口
wg-quick down wgcf

# 加入开机启动
systemctl start wg-quick@wgcf
systemctl enable wg-quick@wgcf

0 条评论

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理