天天看点

三层交换机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

全部互通

继续阅读