1. 程式人生 > 實用技巧 >三層交換機實現VLAN間通訊(附視訊)

三層交換機實現VLAN間通訊(附視訊)

拓撲如下: 實驗步驟: 任務描述:通過三層交換機的路由介面,實現VLAN間通訊。注意開啟三層交換機上路由功能。 Switch0上配置管理VLAN Switch0> Switch0>enable Switch0#configure terminal Switch0(config)#interface range g1/1-2 Switch0(config)#switchport mode trunk Switch0(config)#vtp domain jsjgs Changing VTP domain name from null to jsjgs Switch0(config)#vlan 10
Switch0(config-vlan)#name HR Switch0(config-vlan)#exit Switch0(config)#vlan 20 Switch0(config-vlan)#name engineer Switch0(config-vlan)#exit Switch0(config)#vlan 30 Switch0(config-vlan)#name market Switch0(config-vlan)#end Switch0#show vtp status VTP Version : 2 Configuration Revision :3 Maximum VLANs supported locally : 255
Number of existing VLANs : 8 VTP Operating Mode : Server VTP Domain Name : jsjgs VTP Pruning Mode : Disabled VTP V2 Mode : Disabled VTP Traps Generation : Disabled MD5 digest : 0x<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />0A 0x3C 0x10 0x59 0x3E 0x41 0x7A 0x6F
Configuration last modified by 0.0.0.0 at 3-1-93 00:12:47 Local updater ID is 0.0.0.0 (no valid interface found) <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Switch0#Switch0#show vlan brief

VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22 10 HR active Fa0/23 20 engineer active Fa0/24 30 market active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active

Switch0#

在交換機switch1上將相應埠新增到VLAN Switch1#configure terminal Switch1(config)#interface range f0/1-15 Switch1(config-if-range)#Switch1port mode access Switch1(config-if-range)#Switch1port access vlan 10 Switch1(config-if-range)#exit Switch1(config)#interface range f0/16-22 Switch1(config-if-range)#Switch1port mode access Switch1(config-if-range)#Switch1port access vlan 20 Switch1(config-if-range)#end

Switch1#show vlan brief

VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/23, Fa0/24, Gig1/2 10 HR active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15 20 engineer active Fa0/16, Fa0/17, Fa0/18, Fa0/19 Fa0/20, Fa0/21, Fa0/22 30 market active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active Switch1#

同樣在Switch2完成相應操作: Switch2#show vlan brief

VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/23, Fa0/24, Gig1/1 10 HR active 20 engineer active Fa0/16, Fa0/17, Fa0/18, Fa0/19 Fa0/20, Fa0/21, Fa0/22 30 market active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active Switch2#

至此,二層配置完成。 接下來完成三層通訊所需要的配置: 在交換機Switch0上,設定相關介面turnk模式: Switch0#configure terminal Switch0(config)#interface f0/22 Switch0(config-if)#switchport mode access Switch0(config-if)#switchport access vlan 10 Switch0(config-if)#exit Switch0(config)#interface f0/23 Switch0(config-if)#switchport mode access Switch0(config-if)#switchport access vlan 20 Switch0(config-if)#exit Switch0(config)#interface f0/24 Switch0(config-if)#switchport mode access Switch0(config-if)#switchport access vlan 30 Switch0(config-if)#end Switch0#show vlan brief

VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4 Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21 10 HR active Fa0/22 20 engineer active Fa0/23 30 market active Fa0/24 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active Switch0# 在三層交換機上啟用路由介面,配置IP地址: Switch>enable Switch#configure terminal Switch(config)#hostname SwitchL3 SwitchL3(config)#interface f0/22 SwitchL3(config-if)#no switchport SwitchL3(config-if)#ip address 192.168.1.254 255.255.255.0 SwitchL3(config-if)#no shutdown SwitchL3(config-if)#exit SwitchL3(config)#interface f0/23 SwitchL3(config-if)#no switchport SwitchL3(config-if)#ip address 192.168.2.254 255.255.255.0 SwitchL3(config-if)#no shutdown SwitchL3(config-if)#exit SwitchL3(config)#interface f0/24 SwitchL3(config-if)#no switchport SwitchL3(config-if)#ip address 192.168.3.254 255.255.255.0 SwitchL3(config-if)#no switchport SwitchL3(config-if)#exit SwitchL3(config)#ip routing SwitchL3(config)#end SwitchL3#show ip rou SwitchL3#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route

Gateway of last resort is not set

C 192.168.1.0/24 is directly connected, FastEthernet0/22 C 192.168.2.0/24 is directly connected, FastEthernet0/23 C 192.168.3.0/24 is directly connected, FastEthernet0/24 SwitchL3#

在主機上設定相應的閘道器: 視訊如下 (全部下載後一同解壓)