学习目标
·掌握通过三层交换机实现VLAN间通信的配置方法
·掌握通过以太网Trunk链路实现VLAN间通信的配置方法
拓扑图
图1.4 三层交换实验拓扑图
场景
在企业网络中,通过使用三层交换机可以简便的实现VLAN间通信。作为企业的网络管理员,您需要在三层交换机配置VLANIF接口的三层功能,使得如上所示拓扑图中的网络能够实现VLAN间通信。
操作步骤
步骤一实验环境准备
为了保证实验结果的准确性,确保设备以空配置启动。
步骤二清除设备上原有的配置
如果设备有配置,请清除配置。
清除配置命令reset saved-configuration
清除后重启设备命令reboot
等设备重启动完成,就是空配置了。
步骤三在SW1、SW2上创建VLAN 2和VLAN3
配置SW1
<Huawei>system-view
[Huawei]sysname SW1
[SW1]vlan 2
[SW1-vlan2]quit
[SW1]vlan 3
[SW1-vlan3]quit
[SW1]
配置SW2
<Huawei>system-view
[Huawei]sysname SW2
[SW2]vlan 2
[SW2-vlan2]quit
[SW2]vlan 3
[SW2-vlan3]quit
[SW2]
确认VLAN已成功创建。
[SW1]display vlan
[SW2]display vlan
步骤四把端口加入相应VLAN
将SW2上的G0/0/1和0/0/2端口分别加入VLAN 2和VLAN 3。
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 2
[SW2-GigabitEthernet0/0/1]quit
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 3
[SW2-GigabitEthernet0/0/2]quit
[SW2]
配置完成后,在SW2上执行display vlan命令查看VLAN以及成员端口信息。
[SW2]display vlan
步骤五配置Trunk
配置SW1和SW2互连的接口G0/0/24为trunk,并允许VLAN2,VLAN3通过。
配置SW1
[SW1]interface GigabitEthernet 0/0/24
[SW1-GigabitEthernet0/0/24]port link-type trunk
[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan 2 3
[SW1-GigabitEthernet0/0/24]quit
配置SW2
[SW2]interface GigabitEthernet 0/0/24
[SW2-GigabitEthernet0/0/24]port link-type trunk
[SW2-GigabitEthernet0/0/24]port trunk allow-pass vlan 2 3
[SW2-GigabitEthernet0/0/24]quit
配置完成后,在SW1和SW2上执行display cur命令查看配置。
[SW2]display current-configuration
步骤六配置VLANIF三层接口
在SW1上为VLAN2, VLAN3创建三层接口VLANIF 2和VLANIF 3,并配置IP地址。
配置SW1
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip address 10.1.2.254 255.255.255.0
[SW1-Vlanif2]quit
[SW1]interface vlan 3
[SW1-Vlanif3]ip address 10.1.3.254 255.255.255.0
[SW1-Vlanif3]quit
配置完成后,在SW1上执行display cur命令查看配置。
[SW1]display current-configuration
[SW1]display ip interface brief
[SW1]display ip interface brief
InterfaceIP Address/MaskPhysical Protocol
Vlanif2 10.1.2.254/24 up up
Vlanif3 10.1.3.254/24 up up
步骤七检测VLAN 2和VLAN 3间的连通性
测试PC1和PC2之间的连通性。
PC1>ping 10.1.3.2
Ping 10.1.3.2: 32 data bytes, Press Ctrl_C to break
From 10.1.3.2: bytes=32 seq=1 ttl=127 time=140 ms
From 10.1.3.2: bytes=32 seq=2 ttl=127 time=94 ms
From 10.1.3.2: bytes=32 seq=3 ttl=127 time=94 ms
From 10.1.3.2: bytes=32 seq=4 ttl=127 time=110 ms
From 10.1.3.2: bytes=32 seq=5 ttl=127 time=78 ms
回显信息表明VLAN2的PC1和VLAN3的PC2可以互相通信。
配置文件
[SW]display current-configuration
[SW2]display current-configuration