交换机B1-AS-1和路由器B1-R通过一条双绞线连接,VLAN4和VLAN9的用户PC分别连到B1-AS-1,如上图所示,VLAN4的用户PC1和VLAN9的用户PC2通过B1-R互通。 2、实验步骤
3、配置流程
创建VLAN 配置端口VLAN相关 创建三层接口 Step1:创建VLAN
[B1-AS-1]vlan batch 4 9 [B1-AS-1-vlan4]quit
[B1-AS-1]interface Ethernet 0/0/1
[B1-AS-1-Ethernet0/0/1]port link-type access [B1-AS-1-Ethernet0/0/1]port default vlan 4 [B1-AS-1-Ethernet0/0/1]quit [B1-AS-1]interface Ethernet 0/0/2
[B1-AS-1-Ethernet0/0/2]port link-type access [B1-AS-1-Ethernet0/0/2]port default vlan 9
Step2: 配置Trunk端口
[B1-AS-1]interface Ethernet 0/0/24
[B1-AS-1-Ethernet0/0/24]port link-type trunk
[B1-AS-1-Ethernet0/0/24]port trunk allow-pass vlan 4 9
Step3:配置路由器子接口
[B1-R]interface GigabitEthernet 0/0/0.4
[B1-R-GigabitEthernet0/0/0.4] control-vid 4 dot1q-termination #区分
子接口并配置其封装方式#
[B1-R-GigabitEthernet0/0/0.4] dot1q termination vid 4 #配置dot1q终结功能#
[B1-R-GigabitEthernet0/0/0.4] ip address 10.1.7.1 26 [B1-R-GigabitEthernet0/0/0.4]quit
[B1-R]interface GigabitEthernet 0/0/0.9
[B1-R-GigabitEthernet0/0/0.9] control-vid 9 dot1q-termination [B1-R-GigabitEthernet0/0/0.9] dot1q termination vid 9 [B1-R-Ethernet0/1.9]ip address 10.1.7.65 27
Step4:三层交换(选做)
在以上实验中将路由器B1-R采用交换接口连接交换机(即将路由器B1-R换成交换机B1-AS-2),那么在三层交换机的配置和路由器的配置基本类似,假设交换机B1-AS-2通过接口Ethernet0/0/0连接交换机,其配置如下:
[B1-AS-2]vlan 4 [B1-AS-2]vlan 9
[B1-AS-2] interface Ethernet 0/0/0
[B1-AS-2-Ethernet0/0/0] port link-type trunk
[B1-AS-2-Ethernet0/0/0] port trunk allow-pass vlan 4 9 [B1-AS-2-Ethernet0/0/0]quit [B1-AS-2] interface Vlanif 4
[B1-AS-2-Vlanif4]ip address 10.1.7.1 26 [B1-AS-2-Vlanif4]quit
[B1-AS-2-Ethernet0/0/0] interface Vlanif 9 [B1-AS-2-Vlanif9]ip address 10.1.7.65 27
五、结果验证
Step1:查看IP路由表
[HQ-CS-A]display ip routing-table
路由表中新增了哪些信息?将路由表截图保存
Step2: 连通性检查
使用Ping命令检查PC1和PC2间的连通性。可以看到属于VLAN4的PC1和属于
VLAN9的PC2可以互访。
选做图