实验目的
pc1 pc3 都是vlan10 pc2 pc4都是vlan20
实现不同vlan之间通信
拓扑图如下
实验步骤如下
[sw2]vlan batch 10 20 //在sw2上设置vlan 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2]int e0/0/2 //进入接口
[sw2-Ethernet0/0/2]port link-type access //设置接口模式
[sw2-Ethernet0/0/2]p d v 10 //在接口设置vlan、
[sw2-Ethernet0/0/2]int e0/0/3 //进入0/0/3接口设置
[sw2-Ethernet0/0/3]p l a
[sw2-Ethernet0/0/3]p d v 20 //设置vlan20
[sw2-Ethernet0/0/3]un sh
[sw2-Ethernet0/0/2]int e0/0/1 //进入0/0/1接口
[sw2-Ethernet0/0/1]p l t //设置trunk
[sw2-Ethernet0/0/1]p t a v a
[sw2-Ethernet0/0/1]int g0/0/1 //进入接口设置trunk
[sw2-GigabitEthernet0/0/1]p l t
[sw2-GigabitEthernet0/0/1]p t a v a
在sw3上设置
[sw3]vlan b
[sw3]vlan batch 10 20 //在sw3 设置vlan 10 20
[sw3]int e0/0/2 2入0/0/2接口设置access
[sw3-Ethernet0/0/2]p l a
[sw3-Ethernet0/0/2]p d v 10 //在接口设置vlan10
[sw3-Ethernet0/0/2]un sh
[sw3-Ethernet0/0/2]int e0/0/3 //进入0/0/3 设置access
[sw3-Ethernet0/0/3]p l a
[sw3-Ethernet0/0/3]p d v 20
[sw3-Ethernet0/0/3]int e0/0/1 /在0/0/1接口设置trunk
[sw3-Ethernet0/0/1]p l t
[sw3-Ethernet0/0/1]p t a v a
[sw3-Ethernet0/0/1]un sh
sw1
[Huawei]vlan b
[Huawei]vlan batch 10 20 1000 //在sw1设置 vlan10 20 100
sw1]int g0/0/1 //在0/0/1设置trunk
[sw1-GigabitEthernet0/0/1]p l t
[sw1-GigabitEthernet0/0/1]p t a v a
[sw1]int vlanif 10 /进入子接口设置
[sw1-Vlanif10]ip add 192.168.10.1 24 设置IP地址
[sw1-Vlanif10]un sh
Info: Interface Vlanif10 is not shutdown.
[sw1-Vlanif10]int vlanif 20 //进入子接口
[sw1-Vlanif20]ip add 192.168.20.1 24
[sw1-Vlanif20]un sh
sw1-GigabitEthernet0/0/1]int g0/0/2 //进入0/0/2接口
[sw1-GigabitEthernet0/0/2]p l a /设置acces
[sw1-GigabitEthernet0/0/2]p d v 1000 //设置vlan1000
[sw1-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[sw1-GigabitEthernet0/0/2]q
[sw1]int vlanif 1000 //进入vlan1000
[sw1-Vlanif1000]ip add 11.0.0.1 30 //在vlan1000 设置IP地址
[sw1]ip route-static 0.0.0.0 0.0.0.0 11.0.0.2 //设置默认路由指向r1
在R1设置
[R1]int g0/0/0 //在0/0/0设置IP地址
[R1-GigabitEthernet0/0/0]ip add 11.0.0.2 30
[R1]int loo 0 //设置loopback 0
[R1-LoopBack0]ip add 1.1.1.1 30
pc1可以ping通pc2