36位粉絲
1.交換機SW2的配置
先在交換機上加VLAN 10 20,再設定介面傳輸模式為access口
<Huawei>sy
[Huawei]vlan bat 10 20 #批次加vlan10和20
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]portlink-type ac
[Huawei-Ethernet0/0/1]port link-typeaccess #介面型別為access
[Huawei-Ethernet0/0/1]port defaultvlan 10 #讓介面屬於vlan10
[Huawei-Ethernet0/0/1]inte0/0/2
[Huawei-Ethernet0/0/2]portlink-type ac
[Huawei-Ethernet0/0/2]portlink-type access
[Huawei-Ethernet0/0/2]portde
[Huawei-Ethernet0/0/2]portdefault vlan 20
[Huawei-Ethernet0/0/2]intg0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk #將g0/0/1設為trunk 中繼口
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 1 10 20
#此中繼介面允許vlan1 10 20的資料過,也稱透傳
用display vlan
spacer.gif spacer.gif
l 給交換機SW2配IP地址和閘道器,便於遠端管理
因為交換機的介面是二層介面不能陪IP,所以給交換機配IP只能為其VLAN虛擬口配IP
[Huawei]int vlan 1
[Huawei-Vlanif1]ip add192.168.1.254 24
[Huawei-Vlanif1]q
在華為模擬器上透過設預設路由的方式為其設定閘道器
[Huawei]ip route-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
[Huawei]
用display ip interface brief檢視各介面配置
2.交換機SW3的配置
為交換機SW3配VLAN,介面傳輸模式為hybrid untagged模式,hybriduntagged模式不帶標籤相當於access模式,hybrid tagged模式帶標籤相當於trunk模式
[Huawei]vlan bat 10 20
[Huawei]interface e0/0/3
[Huawei-Ethernet0/0/3]portlink-type hybrid #將介面型別設為hybrid混合介面,華為三層交換機介面預設就是hybrid,屬於這條命令可以不用寫
[Huawei-Ethernet0/0/3]port hybridpvid vlan 10
[Huawei-Ethernet0/0/3]porthy
[Huawei-Ethernet0/0/3]porthybrid un
[Huawei-Ethernet0/0/3]porthybrid untagged
[Huawei-Ethernet0/0/3]porthybrid untagged vlan 10 #允許vlan10 的資料過且不帶標籤
[Huawei-Ethernet0/0/3]inte0/0/4
[Huawei-Ethernet0/0/4]porthybrid pvid vlan 20
[Huawei-Ethernet0/0/4]porthybrid un
[Huawei-Ethernet0/0/4]porthybrid untagged vlan 20
[Huawei-Ethernet0/0/4]
[Huawei-Ethernet0/0/4]intg0/0/1
[Huawei-GigabitEthernet0/0/1]porthybrid pvid vlan 10
[Huawei-GigabitEthernet0/0/1]porthybrid pvid vlan 20
[Huawei-GigabitEthernet0/0/1]porthy
[Huawei-GigabitEthernet0/0/1]porthybrid t
[Huawei-GigabitEthernet0/0/1]porthybrid tagged vlan 10 20
#允許vlan10 20的資料透過且帶標籤
用display vlan檢視vlan配置
給交換機vlan1配ip地址和閘道器,便於遠端管理
[Huawei-GigabitEthernet0/0/1]intvlan 1
[Huawei-Vlanif1]ip add192.168.1.253 24
3.三層交換機SW1的配置
給交換機SW1配vlan
[Huawei]vlan bat 10 20 100
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]portlink-type trunk
[Huawei-GigabitEthernet0/0/1]porttrunk allow-pass vlan 1 10 20
[Huawei-GigabitEthernet0/0/1]intg0/0/2
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 1
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 10
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 20
[Huawei-GigabitEthernet0/0/2]porthybrid un
[Huawei-GigabitEthernet0/0/2]port hybriduntagged vlan 1 10 20
[Huawei-GigabitEthernet0/0/2]intg0/0/3
[Huawei-GigabitEthernet0/0/3]portlink-type ac
[Huawei-GigabitEthernet0/0/3]portlink-type access
[Huawei-GigabitEthernet0/0/3]portde
[Huawei-GigabitEthernet0/0/3]portdefault vlan 100
給vlan110 20 100配ip地址
[Huawei-GigabitEthernet0/0/3]intvlan 1
[Huawei-Vlanif1]ipadd 192.168.1.1 24
[Huawei-Vlanif1]
[Huawei]intvlan 10
[Huawei-Vlanif10]
[Huawei-Vlanif10]ip add192.168.10.1 24
[Huawei-Vlanif10]int vlan20
[Huawei-Vlanif20]ip add192.168.20.1 24
[Huawei-Vlanif20]
[Huawei-Vlanif20]int vlan100
[Huawei-Vlanif100]ip add201.100.100.1 24
為交換機配預設路由
[Huawei]iproute-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 201.100.100.24.路由器R1 的配置
給路由器R1介面配ip地址和預設路由
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ipadd 201.100.100.2 24
[Huawei]ip route-static 0.0.0.0 0.0.0.0 201.100.100.1
用display ip int b檢視介面配置,用displayip routing-t檢視路由表
4).驗證結果
因為C1和C3屬於vlan10,C2和C4屬於vlan20,如果沒有做vlan間路由,不同vlan間的成員是無法通訊的,現在用C1 ping C2、C4和R1就說明vlan間路由是做成功的
36位粉絲
1.交換機SW2的配置
先在交換機上加VLAN 10 20,再設定介面傳輸模式為access口
<Huawei>sy
[Huawei]vlan bat 10 20 #批次加vlan10和20
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]portlink-type ac
[Huawei-Ethernet0/0/1]port link-typeaccess #介面型別為access
[Huawei-Ethernet0/0/1]port defaultvlan 10 #讓介面屬於vlan10
[Huawei-Ethernet0/0/1]inte0/0/2
[Huawei-Ethernet0/0/2]portlink-type ac
[Huawei-Ethernet0/0/2]portlink-type access
[Huawei-Ethernet0/0/2]portde
[Huawei-Ethernet0/0/2]portdefault vlan 20
[Huawei-Ethernet0/0/2]intg0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk #將g0/0/1設為trunk 中繼口
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 1 10 20
#此中繼介面允許vlan1 10 20的資料過,也稱透傳
用display vlan
spacer.gif spacer.gif
l 給交換機SW2配IP地址和閘道器,便於遠端管理
因為交換機的介面是二層介面不能陪IP,所以給交換機配IP只能為其VLAN虛擬口配IP
[Huawei]int vlan 1
[Huawei-Vlanif1]ip add192.168.1.254 24
[Huawei-Vlanif1]q
在華為模擬器上透過設預設路由的方式為其設定閘道器
[Huawei]ip route-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
[Huawei]
用display ip interface brief檢視各介面配置
2.交換機SW3的配置
為交換機SW3配VLAN,介面傳輸模式為hybrid untagged模式,hybriduntagged模式不帶標籤相當於access模式,hybrid tagged模式帶標籤相當於trunk模式
<Huawei>sy
[Huawei]vlan bat 10 20
[Huawei]interface e0/0/3
[Huawei-Ethernet0/0/3]portlink-type hybrid #將介面型別設為hybrid混合介面,華為三層交換機介面預設就是hybrid,屬於這條命令可以不用寫
[Huawei-Ethernet0/0/3]port hybridpvid vlan 10
[Huawei-Ethernet0/0/3]porthy
[Huawei-Ethernet0/0/3]porthybrid un
[Huawei-Ethernet0/0/3]porthybrid untagged
[Huawei-Ethernet0/0/3]porthybrid untagged vlan 10 #允許vlan10 的資料過且不帶標籤
[Huawei-Ethernet0/0/3]inte0/0/4
[Huawei-Ethernet0/0/4]porthybrid pvid vlan 20
[Huawei-Ethernet0/0/4]porthybrid un
[Huawei-Ethernet0/0/4]porthybrid untagged vlan 20
[Huawei-Ethernet0/0/4]
[Huawei-Ethernet0/0/4]intg0/0/1
[Huawei-GigabitEthernet0/0/1]porthybrid pvid vlan 10
[Huawei-GigabitEthernet0/0/1]porthybrid pvid vlan 20
[Huawei-GigabitEthernet0/0/1]porthy
[Huawei-GigabitEthernet0/0/1]porthybrid t
[Huawei-GigabitEthernet0/0/1]porthybrid tagged vlan 10 20
#允許vlan10 20的資料透過且帶標籤
用display vlan檢視vlan配置
給交換機vlan1配ip地址和閘道器,便於遠端管理
[Huawei-GigabitEthernet0/0/1]intvlan 1
[Huawei-Vlanif1]ip add192.168.1.253 24
[Huawei-Vlanif1]q
[Huawei]ip route-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1
[Huawei]
3.三層交換機SW1的配置
給交換機SW1配vlan
<Huawei>sy
[Huawei]vlan bat 10 20 100
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]portlink-type trunk
[Huawei-GigabitEthernet0/0/1]porttrunk allow-pass vlan 1 10 20
[Huawei-GigabitEthernet0/0/1]intg0/0/2
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 1
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 10
[Huawei-GigabitEthernet0/0/2]port hybridpvid vlan 20
[Huawei-GigabitEthernet0/0/2]porthybrid un
[Huawei-GigabitEthernet0/0/2]port hybriduntagged vlan 1 10 20
[Huawei-GigabitEthernet0/0/2]intg0/0/3
[Huawei-GigabitEthernet0/0/3]portlink-type ac
[Huawei-GigabitEthernet0/0/3]portlink-type access
[Huawei-GigabitEthernet0/0/3]portde
[Huawei-GigabitEthernet0/0/3]portdefault vlan 100
給vlan110 20 100配ip地址
[Huawei-GigabitEthernet0/0/3]intvlan 1
[Huawei-Vlanif1]ipadd 192.168.1.1 24
[Huawei-Vlanif1]
[Huawei]intvlan 10
[Huawei-Vlanif10]
[Huawei-Vlanif10]ip add192.168.10.1 24
[Huawei-Vlanif10]
[Huawei-Vlanif10]int vlan20
[Huawei-Vlanif20]ip add192.168.20.1 24
[Huawei-Vlanif20]
[Huawei-Vlanif20]int vlan100
[Huawei-Vlanif100]ip add201.100.100.1 24
為交換機配預設路由
[Huawei]iproute-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 201.100.100.24.路由器R1 的配置
給路由器R1介面配ip地址和預設路由
<Huawei>sy
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ipadd 201.100.100.2 24
[Huawei]ip route-s
[Huawei]ip route-static 0.0.0.0 0.0.0.0 201.100.100.1
用display ip int b檢視介面配置,用displayip routing-t檢視路由表
4).驗證結果
因為C1和C3屬於vlan10,C2和C4屬於vlan20,如果沒有做vlan間路由,不同vlan間的成員是無法通訊的,現在用C1 ping C2、C4和R1就說明vlan間路由是做成功的