欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

6to4隧道

发布时间:2023/12/20 编程问答 33 豆豆
生活随笔 收集整理的这篇文章主要介绍了 6to4隧道 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

6to4隧道

6rd隧道测试:https://blog.csdn.net/zdl244/article/details/103280256


6to4隧道定义了一个网络前缀2002::/16用于表达这是一个6to4网络整体,
地址格式2002:a.b.c.d:xxxx:xxxx:xxxx:xxxx:xxxx,(a.b.c.d是IPv4地址)
       任何一个公共IPv4地址将地址的十六进制值加在6to4网络前缀之后,从而产生一个前缀数为48的相应IPv4的6to4子网的网络前缀,而且其仍然可以继续分割至最小前缀数为64的子网段用于区分出这个6to4子网的子网。

测试环境

使用两台Centos主机ipv4地址是192.168.1.107和192.168.2.108充当路由器,实现6to4隧道,前缀是2002::/16


拓扑图:
主机A(192.168.1.107)--------路由器---------主机B(192.168.2.108)

192.168.1.107配置:

[root@RA ~]# ip tunnel add 6to4 mode sit remote any local 192.168.1.107 [root@RA ~]# ip -6 addr add 2002:c0a8:016b:2019::1/64 dev 6to4 #配置隧道接口地址,192.168.1.107转换成16进制是"c0a8:016b" [root@RA ~]# ip link set 6to4 up [root@RA ~]# route -6 add 2002:c0a8:026c::/48 dev 6to4 #将对端2002:c0a8:026c::/48的路由指向隧道接口

192.168.2.108配置:

[root@RB ~]# ip tunnel add 6to4 mode sit remote any local 192.168.2.108 [root@RB ~]# ip -6 addr add 2002:c0a8:026c:2019::1/64 dev 6to4 [root@RB ~]# ip link set 6to4 up [root@RB ~]# route -6 add 2002:c0a8:016b::/48 dev 6to4

在主机A测试ping6主机B可达。

[root@RA ~]# ping6 2002:c0a8:026c:2019::1 PING 2002:c0a8:026c:2019::1(2002:c0a8:26c:2019::1) 56 data bytes 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=1 ttl=64 time=0.551 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=2 ttl=64 time=0.669 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=3 ttl=64 time=0.563 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=4 ttl=64 time=0.590 ms ^C --- 2002:c0a8:026c:2019::1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3000ms rtt min/avg/max/mdev = 0.551/0.593/0.669/0.049 ms

增加lo接口地址测试:

[root@RA ~]# ip -6 addr add 2002:c0a8:016b:2018::1/64 dev lo [root@RA ~]# ping6 -I 2002:c0a8:016b:2018::1 2002:c0a8:026c:2019::1 PING 2002:c0a8:026c:2019::1(2002:c0a8:26c:2019::1) from 2002:c0a8:16b:2018::1 : 56 data bytes 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=1 ttl=64 time=0.644 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=2 ttl=64 time=0.600 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=3 ttl=64 time=0.638 ms 64 bytes from 2002:c0a8:26c:2019::1: icmp_seq=4 ttl=64 time=0.560 ms ^C --- 2002:c0a8:026c:2019::1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3002ms rtt min/avg/max/mdev = 0.560/0.610/0.644/0.041 ms

总结

以上是生活随笔为你收集整理的6to4隧道的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。