话接上篇我们基于腾讯云主机搭建了DPDK+VPP的学习平台,接下来学习vlan dot1q终结功能的配置及流程转发流程。下面首先来了解一下BD域的一些概念。 dot1q终结子接口的主要作用是通过识别和处理报文中的VLAN Tag,实现不同VLAN网络之间的三层互通,从而支持更复杂的网络架构和提高网络通信效率。 下面是l2-input-vtr和l2-ouput节点配置结构体关系图: 至此我们简单了解了一些dot1q终结子接口的配置说明。VPP中L2相关处理时一个很复杂的模块。 参考资料: 1、华为交换机dot1q终止vid命令详解: https://support.huawei.com/enterprise/zh/doc/EDOC1000128396/c51dda43 2、
vlan 3 或者使用 vlan batch 2 to 3 10 int e 0/0/1 port link-type access port default vlan 2 vlan间通信 通过Dot1q 跟VLANIF接口一样,在子接口上配置Dot1q终结功能和IP地址后,设备也会添加相应的MAC表项并置位三层转发标志位,进而实现VLAN间的三层互通。 Dot1q终结子接口适用于通过一个三层以太网接口下接多个VLAN网络的环境。 dot1q termination vid vlan-id命令用来配置子接口Dot1q终结的VLAN ID。 [R1]int g 0/0/1.2 dot1q termination vid 2 arp broadcast enable ip address 192.168.2.254 24 quit int g 0/0/1.3 dot1q termination vid 3 arp broadcast enable ip address 192.168.3.254 24 quit
前面一篇文章《learning:vpp实现dot1q终结功能配置》介绍了vlan dot1q终结子接口功能配置,下面参考vpp官方文档介绍一下创建vlan子接口的命令行。 如果未输入dot1q或dot1ad,则默认行为是完全匹配exact-match模式。 802.1q(dot1q)和802.1ad(QINQ)区别: 802.1Q就是我们常说的dot1q,IEEE 802.1Q -英文缩写写为dot1q。 dot就是点的意思,就简写为dot1q了。 dot1q和dot1ad的TPID(Tag Protocol Identifier,标签协议标识符)有不同的值。
int g0/0/0.10 进入0/0/0.10子接口 dot1q termination vid 10 给子接口封装dot1q协议 允许vlan10通过 ip add 10.1.1.1 24 给子接口配上IP地址 arp broadcast enable 启动ARP的广播功能 int g0/0/0.20 进入0/0/0.20的子接口 dot1q termination vid 20 给子接口封装 dot1q协议,允许vlan20通过 ip add 20.1.1.1 24 给子接口配上IP地址 arp broadcast enable 启动ARP广播功能
通过子接口实现多个 VLAN 之间的三层互通 HCIA 出现频率:★★★★★(几乎必考) 二、实验目标 通过本实验,你将掌握: VLAN 创建与 Access 口配置 Trunk 链路配置 路由器 子接口 的使用 dot1q sysname AR1 2️⃣ 创建 VLAN 10 子接口 [AR1] interface GigabitEthernet 0/0/0.10 [AR1-GigabitEthernet0/0/0.10] dot1q termination vid 10 [AR1-GigabitEthernet0/0/0.10] ip address 192.168.10.254 255.255.255.0 HCIA 超高频命令 dot1q termination vid 10 3️⃣ 创建 VLAN 20 子接口 [AR1] interface GigabitEthernet 0/0/0.20 [AR1-GigabitEthernet0/0/0.20] dot1q UP 3️⃣ 测试连通性 PC1 > ping 192.168.20.2 ✅ 成功即实验完成 九、HCIA 高频易错点总结(非常重要) 错误 后果 Trunk 未放行 VLAN 不通 子接口未 dot1q
trunk allow-pass vlan 2 3 --配置SW的1端口允许VLAN2和Vlan3的数据通过 [R1]int G0/0/1.1 [R1-GigabitEthernet0/0/1.1]dot1q GigabitEthernet0/0/1.1]arp broadcast enable [R1-GigabitEthernet0/0/1.1]int G0/0/1.2 [R1-GigabitEthernet0/0/1.2]dot1q GigabitEthernet0/0/1.2]ip add 192.168.3.254 24 [R1-GigabitEthernet0/0/1.2]arp broadcast enabl int G0/0/1.1 创建子接口、dot1q termination vid 2 配置子接口dot1q封装单层Vlan id、arp broadcast enable 允许终结子接口能转发广播报文 方案三:三层交换 思路:在三层交换机上配置VLANIF 配置命令 dot1q termination vid 的目的是什么? dot1q termination vid 命令有两个功能。第一个功能是删除VLAN标签。
路由: <H3C>sys [H3C]int e 0/0.1 [H3C-Ethernet0/0.1]ip add 192.168.1.1 24 [H3C-Ethernet0/0.1]vlan-type dot1q H3C-Ethernet0/0.1]int e 0/0.2 [H3C-Ethernet0/0.2]ip add 192.168.2.1 24 [H3C-Ethernet0/0.2]vlan-type dot1q CISCO R1(config)#int e0/0 R1(config-if)#no shut R1(config-if)#int e0/0.1 R1(config-subif)#encapsulation dot1Q shut R1(config-subif)#exit R1(config)#int e0/0.2 R1(config-subif)#enca R1(config-subif)#encapsulation dot1Q shut R1(config-subif)#end Switch SW1(config)#int e1/0/1 SW1(config-if)#switchport trunk encapsulation dot1q
0/0/0.1 [AR1-GigabitEthernet0/0/0.1]display this [V200R003C00] # interface GigabitEthernet0/0/0.1 dot1q broadcast enable [HEIKE-GigabitEthernet0/0/0.1]dis thi [V200R003C00] # interface GigabitEthernet0/0/0.1 dot1q broadcast enable [HEIKE-GigabitEthernet0/0/0.2]dis thi [V200R003C00] # interface GigabitEthernet0/0/0.2 dot1q select global [HEIKE-GigabitEthernet0/0/0.2]dis thi [V200R003C00] # interface GigabitEthernet0/0/0.2 dot1q select global [HEIKE-GigabitEthernet0/0/0.1]dis thi [V200R003C00] # interface GigabitEthernet0/0/0.1 dot1q
Dot1q终结子接口 子接口也是一种三层的逻辑接口,跟VLANIF接口一样。通过在子接口上配置Dot1q终结功能和IP地址可以实现VLAN间的三层互通。 与通过VLANIF接口实现VLAN间互通相比,通过Dot1q终结子接口实现VLAN间互通适用于一个以太网接口下接多个VLAN网络的环境。 另外VLANIF接口和Dot1q终结子接口只能实现不同网段的VLAN间互通,通过Super VLAN(即VLAN聚合)和VLAN Switch技术可以实现相同网段的VLAN间互通。 quit [SwitchB] interface gigabitethernet 1/0/1.2 //创建子接口并进入子接口视图 [SwitchB-GigabitEthernet1/0/1.2] dot1q allow-pass vlan 2 to 3 # return SwitchB的配置文件 # sysname SwitchB # interface GigabitEthernet1/0/1.1 dot1q
config-if)#no sh Router(config-if)#exit Router(config)#int g0/0.1 Router(config-subif)#encapsulation dot1Q 10 //封装协议设置为dot1q 允许通过的vlan 为10,dot1Q提供VLAN标识和服务质量(QoS)级别的IEEE标准 Router(config-subif)#ip address 255.255.255.0 Router(config-subif)#exit Router(config)#int g0/0.2 Router(config-subif)#encapsulation dot1q
config)#int g0/0 Router(config)#no shut Router(config-if)#int g0/0.1 Router(config-subif)#encapsulation dot1Q allow-pass vlan all 单臂路由配置 [Huawei>sys [Huawei] [Huawei]int g0/0/0.1 [Huawei-GigabitEthernet0/0/0.1]dot1q Huawei-GigabitEthernet0/0/0.1] [Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2 [Huawei-GigabitEthernet0/0/0.2]dot1q e0/0/0 Router(config-if)#no shut Router(config-if)#int e0/0/0.1 Router(config-subif)#encapsulation dot1Q Router(config-subif)#exit Router(config-subif)#int ethernet 0/0/0.3 Router(config-subif)#encapsulation dot1Q
在具体编码前,我们还是要先解决VLAN数据包构造的问题,在Scapy中我们使用Dot1Q类来构造图3中的Tag部分。如图4。 ? 图4 下面我们可以编写一个跨VLAN的ping请求了。 #! bin/python from scapy.all import * packet = Ether(dst="c0:d3:de:ad:be:ef") / \ Dot1Q (vlan=1) / \ Dot1Q(vlan=2) / \ IP(dst="192.168.13.3") / \ pdst=options.target) return pkt 在构造数据包的部分,我们插入VLAN标识: pkt = Ether(src=mac, dst=target_mac) /Dot1Q (vlan=our_vlan) / Dot1Q(vlan=target_vlan)/ ARP(hwsrc=mac, psrc=args[0], hwdst=target_mac, pdst=options.target
configure terminal Router(config)#hostname RA RA(config)#interface fa0/0.1 RA(config-subif)#encapsulation dot1Q 10 // (1:在路由器上配置trunk的封装协议的命令: // encapsulation [isl/dot1q] vlan# // 2:上面的路由器配置了dot1q中继封装,10 // 3:Trunk的封装类型一共有 ISL和802.1Q两种,而802.1Q在输入的时候为dot1q) RA(config-subif)#ip address 192.168.10.254 255.255.255.0 RA(config-subif)#interface fa0/0.2 RA(config-subif)#encapsulation dot1Q 20 RA(config-subif)#ip address
0/0/0.1 [AR1-GigabitEthernet0/0/0.1]display this [V200R003C00] # interface GigabitEthernet0/0/0.1 dot1q 0/0/0.2 [AR1-GigabitEthernet0/0/0.2]display this [V200R003C00] # interface GigabitEthernet0/0/0.2 dot1q [Y/N]:y [AR1-GigabitEthernet0/0/0.1]dis thi [V200R003C00] # interface GigabitEthernet0/0/0.1 dot1q termination [Y/N]:y [AR1-GigabitEthernet0/0/0.2]display this [V200R003C00] # interface GigabitEthernet0/0/0.2 dot1q
interface Ethernet0/1 switchport trunk encapsulation dot1q switchport mode trunk ! interface Ethernet0/2 switchport trunk encapsulation dot1q switchport mode trunk ! interface Ethernet0/0.11 encapsulation dot1Q 11 ip vrf forwarding Site-1 ip address 10.1.1.1 255.255.255.0 interface Ethernet0/0.22 encapsulation dot1Q 22 ip vrf forwarding Site-2 ip address 10.1.1.1 255.255.255.0 interface Ethernet0/0.11 encapsulation dot1Q 11 ip vrf forwarding Site-1 ip address 10.1.1.2 255.255.255.0
link-type trunk port trunk allow-pass vlan 10 20 30 ③ Router1 三层子接口 interface g0/0/1.10 vlan-type dot1q 10 ip address 192.168.10.1 24 interface g0/0/1.20 vlan-type dot1q 20 ip address 192.168.20.1 24 interface g0/0/1.30 vlan-type dot1q 30 ip address 192.168.30.1 24 ④ Router1 开启OSPF并通往R2 ospf 1 area
link-type trunk port trunk allow-pass vlan 10 20 q q save 3.2 路由器单臂路由配置 sys # 配置子接口0.1 inter g0/0/0.1 dot1q termination vid 10 # dot1q此处第四个字符为一二三的一 ip add 192.168.1.254 24 arp broadcast enable q # 配置子接口0.2 inter g0/0/0.2 dot1q termination vid 20 ip add 192.168.2.254 24 arp broadcast enable q save 3.3 设置电脑
Switch(config)#int fa0/1 Switch(config-if)# switchport trunk encapsulation dot1q Switch(config-if)# Switch(config-if)# no shut Switch(config)#int fa0/2 Switch(config-if)# switchport trunk encapsulation dot1q Switch(config-if)# no shut Switch(config)#int fa0/3 Switch(config-if)# switchport trunk encapsulation dot1q fa0/0.11 Router(config-subif)#no shut Router(config-subif)#en Router(config-subif)#encapsulation dot1q fa0/0.22 Router(config-subif)#no shut Router(config-subif)#en Router(config-subif)#encapsulation dot1q
0.1 ip binding ***-instance A ip address 1.1.1.5 255.255.255.252 ip policy route-policy DJS vlan-type dot1q 1 # interface Ethernet0/0.2 ip binding ***-instance B ip address 1.1.1.5 255.255.255.252 vlan-type dot1q interface GigabitEthernet0/0/0.1 ip binding ***-instance A ip address 1.1.1.6 255.255.255.252 vlan-type dot1q interface GigabitEthernet0/0/0.2 ip binding ***-instance B ip address 1.1.1.6 255.255.255.252 vlan-type dot1q
GigabitEthernet0/0/1.10]ip address 192.168.1.254 24 //配置子接口IP地址,此接口为对应VLAN 网关地址 [R1-GigabitEthernet0/0/1.10]dot1q [R1-GigabitEthernet0/0/1.10]display this [V200R003C00] # interface GigabitEthernet0/0/1.10 dot1q termination //进入子接口配置视图.20 [R1-GigabitEthernet0/0/1.20]ip address 192.168.2.254 24 [R1-GigabitEthernet0/0/1.20]dot1q [R1-GigabitEthernet0/0/1.20]display this [V200R003C00] # interface GigabitEthernet0/0/1.20 dot1q termination