三层交换机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和交换机如图:

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

全部互通

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

M1r4n

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值