實驗拓撲
拓撲分析
Access交換機配置直接可以當作二層交換機,只需要劃分vlan10、vlan20兩個vlan即可。
SW2 g0/0/22 不需要配IP地址,配置成trunk類型。并且創建vlan10 vlan20 ,分別給這兩個vlan配置虛接口IP:Vlanif10 192.168.10.254 24,Vlanif20 192.168.20.254 24
SW2 g0/0/24 不需要配IP地址,只能把G0/0/24加入到vlan99,vlan99配置IP地址接口類型Access,同樣需要給vlan99配置虛接口:Vlanif99 192.168.99.1,用于和路由器(R1)的g0/0/0通訊。
配置步驟
PC配置IP、子掩碼、網關
SW1上二層交換機上劃分VLAN,并把相應的PC接口加入
SW1、SW2之間的兩個端口配置Trunk
SW2上面配置創建VLAN10/20/99,配置VTP,并把24口加入到vlan99,最后加一條靜態路由指向網關。
R1配置接口信息,添加靜態路由
R2配置接口信息,添加靜態路由
SW1 Access接入交換機配置
Access交換機我們可以當他是二層交換機
Thedeviceisrunning!sys Entersystemview,returnuserviewwithCtrl+Z. [Huawei]sysAccess [Access]undoinfo-centerenable#關閉消息提示,這個很煩人 Info:Informationcenterisdisabled. [Access]vlanbatch1020 Info:Thisoperationmaytakeafewseconds.Pleasewaitforamoment...done. [Access]intg0/0/1 [Access-GigabitEthernet0/0/1] [Access-GigabitEthernet0/0/1]portlink-typeaccess [Access-GigabitEthernet0/0/1]portdefaultvlan10 [Access-GigabitEthernet0/0/1]intg0/0/2 [Access-GigabitEthernet0/0/2]portlink-typeaccess [Access-GigabitEthernet0/0/2]portdefaultvlan20 [Access-GigabitEthernet0/0/2]q [Access]intg0/0/22 [Access-GigabitEthernet0/0/22]portlink-typetrunk#配置22為trunk [Access-GigabitEthernet0/0/22]porttrunkallow-passvlan1020#允許vlan10和20通過 [Access-GigabitEthernet0/0/22]q [Access]Userinterfacecon0isavailable
SW2三層交換機的配置
Thedeviceisrunning!sys Entersystemview,returnuserviewwithCtrl+Z. [Huawei]syssw2 [sw2] [sw2]undoinfo-centerenable#關閉消息提示 Info:Informationcenterisdisabled. [sw2] [sw2]vlanbatch1020 Info:Thisoperationmaytakeafewseconds.Pleasewaitforamoment...done. [sw2]intg0/0/22 [sw2-GigabitEthernet0/0/22]portlink-typetrunk [sw2-GigabitEthernet0/0/22]porttrallvlan1020 [sw2-GigabitEthernet0/0/22]porttrunkallow-passvlan1020 [sw2-GigabitEthernet0/0/22]q [sw2]interfaceVlanif10#進入vlan10 [sw2-Vlanif10]ipadd192.168.10.25424#給vlan10虛接口配置IP192.168.10.254 [sw2-Vlanif10]q [sw2]interfaceVlanif20 [sw2-Vlanif20]ipadd192.168.20.25424#給vlan20虛接口配置IP192.168.20.254 [sw2-Vlanif20]q [sw2]vlan99#創建vlan99 [sw2-vlan99]q [sw2]intg0/0/24 [sw2-GigabitEthernet0/0/24]portlink-typeaccess#g0/0/24需要配成access 來源:網絡技術干貨圈 [sw2-GigabitEthernet0/0/24]portdefaultvlan99#g0/0/24加入vlan99 [sw2-GigabitEthernet0/0/24]q [sw2]interfaceVlanif99 [sw2-Vlanif99]ipadd192.168.99.124#給Vlan99虛接口配置IP192.168.99.1 [sw2-Vlanif99]q [sw2]iproute-static0.0.0.00.0.0.0192.168.99.2#加入靜態路由只想網關 PleasePressENTER.
R1路由器配置
Thedeviceisrunning!sys Entersystemview,returnuserviewwithCtrl+Z. [Huawei]sysR1 [R1]undoinfo-centerenable Info:Informationcenterisdisabled. [R1]intg0/0/0 [R1-GigabitEthernet0/0/0]ipadd192.168.99.224 [R1-GigabitEthernet0/0/0]q [R1]iproute-static192.168.10.024192.168.99.1#加入靜態路由 [R1]iproute-static192.168.20.024192.168.99.1#加入靜態路由 [R1]iproute-static192.168.30.02410.10.30.2#加入靜態路由 [R1]displayiprouting-table#查看路由表 RouteFlags:R-relay,D-downloadtofib ------------------------------------------------------------------------------ RoutingTables:Public Destinations:13Routes:13 Destination/MaskProtoPreCostFlagsNextHopInterface 10.10.30.0/24Direct00D10.10.30.1GigabitEthernet0/0/1 10.10.30.1/32Direct00D127.0.0.1GigabitEthernet0/0/1 10.10.30.255/32Direct00D127.0.0.1GigabitEthernet0/0/1 127.0.0.0/8Direct00D127.0.0.1InLoopBack0 127.0.0.1/32Direct00D127.0.0.1InLoopBack0 127.255.255.255/32Direct00D127.0.0.1InLoopBack0 `192.168.10.0/24`Static600RD192.168.99.1GigabitEthernet0/0/0 `192.168.20.0/24`Static600RD192.168.99.1GigabitEthernet0/0/0 `192.168.30.0/24`Static600RD10.10.30.2GigabitEthernet0/0/1 #上面這3條是我們加的 192.168.99.0/24Direct00D192.168.99.2GigabitEthernet0/0/0 192.168.99.2/32Direct00D127.0.0.1GigabitEthernet0/0/0 192.168.99.255/32Direct00D127.0.0.1GigabitEthernet0/0/0 255.255.255.255/32Direct00D127.0.0.1InLoopBack0 [R1]
R2路由器配置
sys Entersystemview,returnuserviewwithCtrl+Z. [Huawei]sysR2 [R2] [R2]intg0/0/0 [R2-GigabitEthernet0/0/0]ipadd10.10.30.224 [R2-GigabitEthernet0/0/0]q [R2]iproute-static0.0.0.00.0.0.010.10.30.1 [R2] [R2]intg0/0/1 [R2-GigabitEthernet0/0/1]ipadd192.168.30.25424 [R2-GigabitEthernet0/0/1]
驗證結果
用PC1ping PC3
PC>ping192.168.30.1 Ping192.168.30.1:32databytes,PressCtrl_Ctobreak Requesttimeout! From192.168.30.1:bytes=32seq=2ttl=125time=63ms From192.168.30.1:bytes=32seq=3ttl=125time=47ms From192.168.30.1:bytes=32seq=4ttl=125time=62ms From192.168.30.1:bytes=32seq=5ttl=125time=47ms ---192.168.30.1pingstatistics--- 5packet(s)transmitted 4packet(s)received 20.00%packetloss round-tripmin/avg/max=0/54/63ms
用PC2ping PC3
PC>ping192.168.30.1 Ping192.168.30.1:32databytes,PressCtrl_Ctobreak From192.168.30.1:bytes=32seq=1ttl=125time=62ms From192.168.30.1:bytes=32seq=2ttl=125time=47ms From192.168.30.1:bytes=32seq=3ttl=125time=62ms From192.168.30.1:bytes=32seq=4ttl=125time=47ms From192.168.30.1:bytes=32seq=5ttl=125time=63ms ---192.168.30.1pingstatistics--- 5packet(s)transmitted 5packet(s)received 0.00%packetloss round-tripmin/avg/max=47/56/63ms PC>
審核編輯:劉清
-
交換機
+關注
關注
21文章
2622瀏覽量
99259 -
路由器
+關注
關注
22文章
3707瀏覽量
113541 -
VLAN技術
+關注
關注
0文章
45瀏覽量
6378 -
VTP
+關注
關注
0文章
4瀏覽量
2293
原文標題:華為路由器:通過三層交換機實現全網互通及訪問外網
文章出處:【微信號:網絡技術干貨圈,微信公眾號:網絡技術干貨圈】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
相關推薦
評論