DS-Lite
DS-Lite
重要
该功能在 7.2.0 及以后版本支持。
DS-Lite 简介
Dual-StackLite,简称 DS-Lite,是一种使用 IPv4overIPv6 隧道将 IPv4 数据包发送到运营商来实现 IPv4 私网地址用户穿越 IPv6 网络访问 IPv4 公网的解决方案。
支持此技术的客户端设备(CPE)会将 IPv4 数据包封装到 IPv6 数据包中,并且将数据包发送至运营商的电信级 NAT(CGNAT)。CGNAT 收到数据包后,将其还原为 IPv4 数据包,在进行 NAT 处理后发送到 IPv4 互联网。CGNAT 通过记录 IPv6 源地址、私有 IPv4 地址,以及 TCP 或 UDP 端口号来标识流量。

DS-Lite 中的几个角色:
B4(Basic Bridging Broadband)和 AFTR(Address Family Transition Router)都具有双栈能力:
- B4 是 IPv4 over IPv6 的创建者,一般位于用户侧(CPE)。
- AFTR 是 IPv4 over IPv6 的终结者,负责 IPv4 over IPv6 报文的解封装与 NAT,一般部署于 ISP 设备上,也被叫作 BR(Border Relay)。
IPv6 和 IPv4 用户都可以正常访问对应 IP 栈的 Internet:
- IPv6 用户通过 B4 和 AFTR 之间的 IPv6 线路直接访问 IPv6 Internet。
- IPv4 用户访问 IPv4 的 Internet,通过 B4 的 IPv4 over IPv6 隧道封装 IPv6 外层 IP 头,到达 AFTR 后,解封装为原始的 IPv4 流量,通过 NAT 转换后访问 IPv4 Internet。

网络拓扑

- B4 与 AFTR(BR)设备均为 FortiGate,之间配置 IPv4 over IPv6 隧道(DS-Lite 类型的 VNE 隧道,Virtual Network Enabler)。
- IPv4 PC1 访问 IPv4 Internet 的流量被 B4 的 VNE 隧道封装为 IPv4 over IPv6 流量送至 AFTR,AFTR 解封装后得到 IPv4 流量,做 SNAT 后送至 IPv4 Internet。
- IPv6 PC2 访问 IPv6 Internet 的流量直接由 B4 和 AFTR 的 IPv6 协议栈转发至 IPv6 Internet。
配置步骤
基础 IPv4/IPv6 双栈网络配置(根据网络拓扑配置,略)。
在 B4 设备上配置 VNE(Virtual Network Enabler)隧道,隧道类型为 DS-Lite,绑定接口为与 AFTR 的接口 wan1,br 地址为 AFTR 的 IPv6 地址,开启 DS-Lite 隧道的加速。
config system vne-tunnel set status enable set interface "wan1" set auto-asic-offload enable set br "2100::1" //也可配置FQDN// set mode ds-lite end在 AFTR 设备上配置反向的 VNE(Virtual Network Enabler)隧道,隧道类型为 DS-Lite,绑定接口为与 AFTR 的接口 wan1,br 地址为 B4 的 IPv6 地址,开启 DS-Lite 隧道的 NP 加速。
config system vne-tunnel set status enable set interface "internal5" set auto-asic-offload enable set br "2100::2" //也可配置FQDN// set mode ds-lite end在 B4 上配置 IPv4 和 IPv6 默认路由,IPv4 默认路由指向 VNE 隧道,IPv6 默认路由指向 AFTR。
config router static edit 5 set device "vne.root" next end config router static6 edit 1 set gateway 2100::1 set device "wan1" next end在 AFTR 设备上配置反向的 IPv4 路由和 IPv6 路由,IPv4 路由指向 VNE 隧道,IPv6 路由指向 B4。
config router static edit 12 set dst 192.168.100.0 255.255.255.0 set device "vne.root" next end config router static6 edit 1 set dst 2200::/64 set gateway 2100::2 set device "internal5" next end在 B4 上配置安全策略,放通 lan 到 VNE 隧道的 IPv4 流量,以及 lan 到 wan1 的 IPv6 流量。
config firewall policy edit 6 set name "dslite" set srcintf "lan" set dstintf "vne.root" set action accept set srcaddr "all" set dstaddr "all" set schedule "always" set service "ALL" edit 7 set name "IPv6" set srcintf "lan" set dstintf "wan1" set action accept set srcaddr6 "all" set dstaddr6 "all" set schedule "always" set service "ALL" next end在 AFTR 设备上配置安全策略,放通 VNE 隧道到 wan1 的 IPv4 流量,开启 SNAT,放通 Internal5 到 wan1 的 IPv6 流量。
config firewall policy edit 11 set name "dslite" set srcintf "vne.root" set dstintf "wan1" set action accept set srcaddr "all" set dstaddr "all" set schedule "always" set service "ALL" set nat enable next edit 12 set srcintf "internal5" set dstintf "wan1" set action accept set srcaddr6 "all" set dstaddr6 "all" set schedule "always" set service "ALL" end
结果验证
在 B4 上查看 VNE 隧道状态。
B4 # diagnose test application vned 1 ---------------------------------------------------------------------------- vdom: root/0, is master, devname=wan1 link=1 tun=vne.root mode=fixed-ip ssl_cert=Fortinet_Factory end user ipv6 perfix: ::/0 interface ipv6 addr: 2100::2 config ipv4 perfix: 0.0.0.0/0.0.0.0 config br: 2100::1 tunnel br: 2100::1 tunnel ipv6 addr: 2100::2 tunnel ipv4 addr: 0.0.0.0/0.0.0.0 DS-Lite rule client: state=succeed retries=0 interval=0 expiry=0 reply_code=0 fqdn=2100::1 num=1 cur=0 ttl=4294967295 expiry=0 2100::1在 AFTR 设备上查看 VNE 隧道状态。
AFTR # diagnose test application vned 1 ---------------------------------------------------------------------------- vdom: root/0, is master, devname=internal5 link=1 tun=vne.root mode=fixed-ip ssl_cert=Fortinet_Factory end user ipv6 perfix: ::/0 interface ipv6 addr: 2100::1 config ipv4 perfix: 0.0.0.0/0.0.0.0 config br: 2100::2 tunnel br: 2100::2 tunnel ipv6 addr: 2100::1 tunnel ipv4 addr: 0.0.0.0/0.0.0.0 DS-Lite rule client: state=succeed retries=0 interval=0 expiry=0 reply_code=0 fqdn=2100::2 num=1 cur=0 ttl=4294967295 expiry=0 2100::2使用 IPv4 PC1 访问 IPv4 Internet,在 B4 和 AFTR 上同时抓包,原始 IPv4 从 B4 的 lan 口收到后,根据 IPv4 默认路由被送入 VNE 接口,VNE 接口封装新的 IPv6 头后,从 wan1 发送给 AFTR,AFTR 收到后,解封装为原始 IPv4,查 IPv4 默认路由从 wan1 发出并做 SNAT,返回流量也是相同的流程。
B4 # diagnose sniffer packet any '(host 223.5.5.5 and icmp) or host 2100::1)' 4 interfaces=[any] filters=[(host 223.5.5.5 and icmp) or host 2100::1] 9.415112 lan in 192.168.100.77 -> 223.5.5.5: icmp: echo request 9.415202 vne.root out 192.168.100.77 -> 223.5.5.5: icmp: echo request 9.415216 wan1 out 2100::2 -> 2100::1: 192.168.100.77 -> 223.5.5.5: icmp: echo request 9.419797 vne.root in 223.5.5.5 -> 192.168.100.77: icmp: echo reply 9.419828 lan out 223.5.5.5 -> 192.168.100.77: icmp: echo reply AFTR # diagnose sniffer packet any '(host 223.5.5.5 and icmp) or host 2100::2' 4 interfaces=[any] filters=[(host 223.5.5.5 and icmp) or host 2100::2] 3.640262 vne.root in 192.168.100.77 -> 223.5.5.5: icmp: echo request 3.640354 wan1 out 172.22.5.77 -> 223.5.5.5: icmp: echo request 3.644756 wan1 in 223.5.5.5 -> 172.22.5.77: icmp: echo reply 3.644785 vne.root out 223.5.5.5 -> 192.168.100.77: icmp: echo reply 3.644801 internal5 out 2100::1 -> 2100::2: 223.5.5.5 -> 192.168.100.77: icmp: echo reply在 B4 上查看 IPv4 流量(VNE 隧道内层)的会话,流量被 NP 加速,无法看到 IPv6 的流量会话。
session info: proto=1 proto_state=00 duration=32 expire=28 timeout=0 flags=00000000 socktype=0 sockport=0 av_idx=0 use=3 class_id=0 ha_id=0 policy_dir=0 tunnel=/ vlan_cos=0/255 state=log may_dirty npu f00 statistic(bytes/packets/allow_err): org=120/2/1 reply=120/2/1 tuples=2 tx speed(Bps/kbps): 0/0 rx speed(Bps/kbps): 0/0 orgin->sink: org pre->post, reply pre->post dev=42->52/52->42 gwy=223.5.5.5/192.168.100.77 hook=pre dir=org act=noop 192.168.100.77:1->223.5.5.5:8(0.0.0.0:0) hook=post dir=reply act=noop 223.5.5.5:1->192.168.100.77:0(0.0.0.0:0) src_mac=00:e0:4c:b9:97:7c misc=0 policy_id=6 pol_uuid_idx=606 auth_info=0 chk_client_info=0 vd=0 serial=007e0aab tos=ff/ff app_list=0 app=0 url_cat=0 rpdb_link_id=00000000 ngfwid=n/a npu_state=0x4000c00 ofld-O ofld-R npu info: flag=0x84/0x81, offload=8/8, ips_offload=0/0, epid=66/95, ipid=95/66, vlan=0x0000/0x0000 vlifid=95/245, vtag_in=0x0000/0x0000 in_npu=1/1, out_npu=1/1, fwd_en=0/0, qid=1/1 B4 # diagnose sys session6 list total session6 0:在 AFTR 上查看 IPv4 流量(VNE 隧道内层)的会话,流量被 NP 加速,无法看到 IPv6 的流量会话。
session info: proto=1 proto_state=00 duration=238 expire=28 timeout=0 flags=00000000 socktype=0 sockport=0 av_idx=0 use=4 class_id=0 ha_id=0 policy_dir=0 tunnel=/ vlan_cos=0/255 state=log may_dirty npu f00 statistic(bytes/packets/allow_err): org=12300/205/1 reply=12300/205/1 tuples=2 tx speed(Bps/kbps): 51/0 rx speed(Bps/kbps): 51/0 orgin->sink: org pre->post, reply pre->post dev=34->5/5->34 gwy=172.22.5.1/192.168.100.77 hook=post dir=org act=snat 192.168.100.77:1->223.5.5.5:8(172.22.5.77:1) hook=pre dir=reply act=dnat 223.5.5.5:1->172.22.5.77:0(192.168.100.77:1) misc=0 policy_id=11 pol_uuid_idx=594 auth_info=0 chk_client_info=0 vd=0 serial=005f4689 tos=ff/ff app_list=0 app=0 url_cat=0 rpdb_link_id=00000000 ngfwid=n/a npu_state=0x4000c00 ofld-O ofld-R npu info: flag=0x81/0x84, offload=8/8, ips_offload=0/0, epid=64/71, ipid=71/64, vlan=0x0000/0x0000 vlifid=247/64, vtag_in=0x0000/0x0000 in_npu=1/1, out_npu=1/1, fwd_en=0/0, qid=1/2 AFTR # diagnose sys session6 list total session6 0:对应的 DS-Lite IPv4 over IPv6 报文,就是 IPv4 over IPv6 封装,没有其他协议层。
