本文主要是介绍Linux隧道6to4,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
6to4地址格式如下:
| 3 | 13 | 32 | 16 | 64 bits |+---+------+-----------+--------+--------------------------------+|FP | TLA | V4ADDR | SLA ID | Interface ID ||001|0x0002| | | |+---+------+-----------+--------+--------------------------------+
其中,
- 前缀长度Prefix length: 48 bits,有三部分组成:
1.Format prefix: 001
2.TLA(Top-Level Aggregation) value: 0x0002
3.NLA(Next-Level Aggregation) value: V4ADDR - SLA(Site-Level Aggregation) ID
- Interface ID
例如,对于IPv4地址192.168.20.1,其对应的6to4地址前缀为:2002:c0a8:1401::/48。如下环境,都是手动配置:
|----------| |----------|| | ens33 ens33 | || Client |--------------------------------| Server || | 192.168.20.5 192.168.20.1 | ||----------| |----------|
Server配置
6to4使用隧道模式sit。
# ip address add 192.168.20.1/24 dev ens33
#
# ip tunnel add tun6to4 mode sit ttl 128 remote 192.168.20.5 local 192.168.20.1
# ip link set dev tun6to4 up
# ip -6 addr add 2002:c0a8:1401::1/16 dev tun6to4
Client配置
# ip address add 192.168.20.5/24 dev ens33
#
# ip tunnel add tun6to4 mode sit ttl 128 remote 192.168.20.1 local 192.168.20.5
# ip link set dev tun6to4 up
# ip -6 addr add 2002:c0a8:1405::5/16 dev tun6to4
测试
# ping 2002:c0a8:1401::1 -c 1
PING 2002:c0a8:1401::1(2002:c0a8:1401::1) 56 data bytes
64 bytes from 2002:c0a8:1401::1: icmp_seq=1 ttl=64 time=0.288 ms--- 2002:c0a8:1401::1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.288/0.288/0.288/0.000 ms
6to4隧道使用协议号41。
这篇关于Linux隧道6to4的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!