Zerotier one 建立公网IPV6隧道桥,异地组网
本文最后更新于 262 天前,其中的信息可能已经有所发展或是发生改变。
  • 一个HE账户
  • 一台Linux系统,文章为Debian11
  • 一个可用的 /48 /64 PD的IPV6,文章使用HE免费IPV6

设置机器的sysctl.conf

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.forwarding = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.forwarding = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.proxy_ndp = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.accept_ra = 2" >> /etc/sysctl.conf

sysctl -p

使用HE 创建隧道

file

  • 创建完成之后,会获得一个IPV6 /64的网络块
  • 只有热门的地区才能申请/48的网络块

file

IPv6 Tunnel Block

这里获取到了一个IPV6的地址
Routed IPv6 Prefixes : 2001:470:36:826::/64

IPv6 Tunnel Endpoints

Server IPv4 Address:216.218.221.42
Server IPv6 Address:2001:470:35:826::1/64
Client IPv6 Address:2001:470:35:826::2/64

机器设置IPV6地址

  • 将显示出来的内容复制下来,下面需要用到
    file

    连接到自己的debian系统

  • vim /etc/network/interfaces
  • local 10.10.201.213 修改为自己机器的外网网卡的IP,建议显示什么就填什么
  • 建议将IPV4的 allow-hotplug 设置为 auto 否则重启网卡概率会失联
    file

    重启网卡

方法一 [基本] [建议使用]

/etc/init.d/networking restart

方法二 [简单]

ifup he-ipv6

查看网卡

file

借助itdog查询地址

file

成功获取到可用IPV6

因为有延迟返回,所以该地址是成功设置上的了

使用Zerotier One来广播IPV6

  • 只要连接上zerotier one的所有机器,都可以获得一个ipv6的公网地址
  • 建议国内用户不要这么操作,体验很差,国外的机器没有ipv6都可以获得一个不错的体验
  • 创建 Zerotier One 账户
  • 创建网络,由下图可见 Network ID为 856127940cf3995d

file

提前规划好 内网 IPV4 + IPV6 以及公网IPV6

内网IPV4

我这边使用的是
100.64.251.1~100.64.251.254

你们可以自行设置,无需和我一样,任意设置即可

file

内网IPV6

  • 两个选项默认打开,无需修改任何
  • 记住ZeroTier RFC4193这个后续路由需要用到
    ZeroTier RFC4193 (/128 for each device)
    ZeroTier 6PLANE (/80 routable for each device)

    file

公网IPV6 HE Tunnel

  • 回到HE找到Routed IPv6 Prefixes的地址 本文以/64 作为演示
  • Routed IPv6 Prefixes : 2001:470:36:826::/64

    借助IPV6在线计算器

  • 在线IPV6计算器 : https://zh.rakko.tools/tools/27/

file

信息 地址
第一个IP地址 2001:0470:0036:0826:0000:0000:0000:0000
最后的IP地址 2001:0470:0036:0826:ffff:ffff:ffff:ffff
子网掩码中的位数 64

file

路由设置

目标地址 类型 路由地址 备注
100.64.251.0/24 (LAN) 默认存在
::/0 Via fd85:6127:940c:f399:5d99:934e:16b3:f508 下文会提及这个地址
2001:470:36:826::/64 (LAN)

file

HE Tunnel机器加入Zerotier

  • 856127940cf3995d 是自己创建的Network ID上文有提及
    curl -s https://install.zerotier.com | sudo bash
    sudo zerotier-cli join 856127940cf3995d
    sudo zerotier-cli set 856127940cf3995d allowGlobal=true
    sudo zerotier-cli set 856127940cf3995d allowDefault=1

查看Zerotier Webui的机器信息

  • 会自动两个内网的IPV6地址
  • 会自动分配一个内网的IPV4地址
  • 会分配一个HE Tunnel /64 的地址

请注意下图红框的地址

  • 红框的地址为 ZeroTier RFC4193 (/128 for each device) 的地址
  • 路由设置Via中需要用到,自行替换
    file

配置IPV6广播

安装 ndppd

apt-get -y install ndppd

/etc/ndppd.conf

  • ens18 替换为自己的外网网卡地址
route-ttl 30000

address-ttl 30000

proxy ens18 {
   router yes
   timeout 500
   autowire no
   keepalive yes
   retries 3
   promiscuous no
   ttl 30000
   rule 2001:470:36:826::/64 {
      auto
      autovia no
   }
}

重启服务,验证

sudo systemctl restart ndppd
sudo systemctl status ndppd

你会发现有Error 不要慌,再重启一次

file

正常了

file

其他的机器加入zerotier one 测试IPV6

以亚马逊AWS Debian为例

curl -s https://install.zerotier.com | sudo bash
sudo zerotier-cli join 856127940cf3995d
sudo zerotier-cli set 856127940cf3995d allowGlobal=true
sudo zerotier-cli set 856127940cf3995d allowDefault=1

查看信息

root@ip-172-31-2-228:~# ifconfig
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.2.228  netmask 255.255.240.0  broadcast 172.31.15.255
        inet6 fe80::87b:d8ff:fee5:87d6  prefixlen 64  scopeid 0x20<link>
        ether 0a:7b:d8:e5:87:d6  txqueuelen 1000  (Ethernet)
        RX packets 33376  bytes 38576966 (38.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11951  bytes 1224372 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 258  bytes 26489 (26.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 258  bytes 26489 (26.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ztcfw5idkr: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 2800
        inet 100.64.251.215  netmask 255.255.255.0  broadcast 100.64.251.255
        inet6 2001:470:36:826:0:c2:a026:26f5  prefixlen 64  scopeid 0x0<global>
        inet6 fc89:92be:c9c2:a026:26f5::1  prefixlen 40  scopeid 0x0<global>
        inet6 fd85:6127:940c:f399:5d99:93c2:a026:26f5  prefixlen 88  scopeid 0x0<global>
        inet6 fe80::5c5b:53ff:fe2a:b2d2  prefixlen 64  scopeid 0x20<link>
        ether 5e:5b:53:2a:b2:d2  txqueuelen 1000  (Ethernet)
        RX packets 1948  bytes 2811480 (2.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 871  bytes 85221 (85.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

可以看到已经获取到了IPV6

地址为 2001:470:36:826:0:c2:a026:26f5

借助ITdog进行测试

file

aws机器安装nginx测试IPV6访问情况

apt-get -y install nginx

借助ITdog进行测试 Nginx

file

zerotier docker容器内运行

docker-compose.yaml

version: '3'
services:
  zerotier-one:
    image: henrist/zerotier-one
    container_name: zerotier-one
    restart: unless-stopped
    network_mode: host
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
    devices:
      - /dev/net/tun
    volumes:
      - ./zerotier-one:/var/lib/zerotier-one
  • 剩下的内容懂得都懂了!
  • 不建议国内的机器这么玩,体验一定不好
  • 别问我ipv6有什么用,问就是没啥用,就是玩

完美结束

感谢下列网站提供的资料

暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇