天天看點

三層交換機Vlan間路由

 材料:

2960一台,3560一台,

pc4台:

pc0:10.10.10.2

pc1:10.10.11.2

pc2:10.10.10.3

pc3:10.10.11.3

連接配接pc和交換機如圖:

三層交換機Vlan間路由

交換機1配置:

Switch>en
Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#exi
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#int f0/1
Switch(config-if)#swi mode tru

Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#
Switch(config-if)#exi
Switch(config)#int f0/2
Switch(config-if)#swi acc vlan 2
Switch(config-if)#exi
Switch(config)#int f0/2
Switch(config-if)#no shut
Switch(config-if)#exi
Switch(config)#int f0/3
Switch(config-if)#swi acc vlan 3
Switch(config-if)#end
           

3560配置:

Switch>en
Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ip routing    //重要 :開啟路由功能
Switch(config)#int f0/1    //交換機之間連接配接口
Switch(config-if)#switchport trunk encapsulation dot1q //給該接口的trunk封裝為802.1Q的幀格式
Switch(config-if)#switchport mode trunk //定義該接口的工作模式為trunk
Switch(config-if)#exi

建立vlan 2和vlan 3
Switch(config)#vlan 2
Switch(config-vlan)#exi
Switch(config)#vlan 3
Switch(config-vlan)#exi

綁定f0/2到vlan 2
綁定f0/3到vlan 3
Switch(config)#int f0/2
Switch(config-if)#swi acc vlan 2
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#swi acc vlan 3
Switch(config-if)#exi

設定vlan ip和開啟vlan虛拟端口
Switch(config)#int vlan 2
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to up
Switch(config-if)#ip add 10.10.10.1 255.255.255.0    //設定vlan2 IP
Switch(config-if)#no shut
Switch(config-if)#exi
Switch(config)#int vlan 3
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan3, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up

Switch(config-if)#ip  add 10.10.11.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#end
           

配置完成,檢視路由

Switch#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

     10.0.0.0/24 is subnetted, 2 subnets
C       10.10.10.0 is directly connected, Vlan2
C       10.10.11.0 is directly connected, Vlan3
           

ping 測試

pc0 ping pc1  reply

pc0 ping pc2  reply

全部互通

繼續閱讀