By accessing the website and accepting the Cookie Policy, you agree to use the cookies provided by the Site in accordance with to analyze traffic, remember your preferences, and optimize your experience.
使 Cloudflared Tunnel 通道支持单 IPv6 网络的服务器通讯,IPv6小鸡变废为宝
2022-09-21 14:32:56    34    0    0
emengweb

这两天在用ks的服务器搭建lxc小鸡,但是发现cf tunnel的流量并不会自动走v6网络,一旦切换到只有ipv6网络时,连接就直接中断了,似乎不支持通过IPv6进行通讯。

这台服务器v6网络是G口,v4网络是100M口,基于此考虑还是希望能走v6网络,获得更快的上行速度。

于是开始翻找资料,发现官方已经与今年7月份的版本开始试验性的支持v6网络,但是需要手动修改服务参数。

以下为具体资料:  

There are three modes available for connecting to the Cloudflare edge:

  • --edge-ip-version auto: Rely on host operating system to determine which IP version to select. The first IP version returned from the DNS resolution of the region lookup will be used as the primary set. In dual IPv6 and IPv4 network setups, cloudflared will separate the IP versions into two address sets that will be used to fallback in connectivity failure scenarios.
  • --edge-ip-version 6: Resolve only IPv6 addresses 
  • --edge-ip-version 4: Resolve only IPv4 addresses (current default)

https://github.com/cloudflare/cloudflared/issues/664

Cloudflared Tunnel 支持以下模式:

  • --edge-ip-version auto: 自动根据DNS获取到的首个地址进行链接,并将另一个种ip地址类型作为备用,在网络中断时会尝试切换
  • --edge-ip-version 6: 只使用IPv6网络
  • --edge-ip-version 4: 只使用IPv4网络(默认)

 

验证

根据这个介绍,尝试在已安装过Cloudflared Tunnel(基于Cloudflare Zero Trust)服务的VPS上进行修改,测试只使用IPv6网络进行通讯,并验证成功。

脚本

下面放出一键修改脚本,可以极大的方便批量部署:

# IPv6
bash <(curl -sL install.emengweb.com/cftunnelv6.sh)
# IPv4
bash <(curl -sL install.emengweb.com/cftunnelv4.sh)
# 自动识别
bash <(curl -sL install.emengweb.com/cftunnelauto.sh) 

源码:

sed -i 's/\/usr\/bin\/cloudflared --edge-ip-version 4/\/usr\/bin\/cloudflared/g' /etc/systemd/system/cloudflared.service
sed -i 's/\/usr\/bin\/cloudflared --edge-ip-version 6/\/usr\/bin\/cloudflared/g' /etc/systemd/system/cloudflared.service
sed -i 's/\/usr\/bin\/cloudflared --edge-ip-version auto/\/usr\/bin\/cloudflared/g' /etc/systemd/system/cloudflared.service
sed -i 's/\/usr\/bin\/cloudflared/\/usr\/bin\/cloudflared --edge-ip-version 6/g' /etc/systemd/system/cloudflared.service

systemctl enable cloudflared
systemctl stop cloudflared
systemctl start cloudflared

echo 'Switch cloudflared tunnel to IPv6 mode' 

 

上一篇: PVE无法引导提示zfs '' invalid for parameter 'zfs_arc_max'进入initramfs模式修复并导入zpool方法记录

下一篇: PVE lxc容器忘记控制台root密码处理办法

34 人读过
文档导航