三层交换配置及RIP动态路由

三层交换配置及RIP动态路由
三层交换vlan间通信
1.1 问题
VLAN实现了⼴播域的隔离,同时也将VLAN间的通信隔离了。三层交换技术使得VLAN间可以通信。
通过三层交换实现VLAN间通信
1.2 ⽅案
为了解决了传统路由器低速、复杂所造成的⽹络瓶颈问题,引⼊了三层交换技术。它根据实际应⽤时的情况,灵活地在⽹络第⼆层或者第三层进⾏⽹络分段。具有三层交换功能的设备是⼀个带有第三层路由功能的第⼆层交换机
简单地说,三层交换技术就是:⼆层交换技术+三层转发技术。
三层交换实现的拓扑如图-1所⽰:
图-1
1.3 步骤
实现此案例需要按照如下步骤进⾏。
步骤⼀:在连接PC的交换机上划分3个VLAN,并按图-1把PC机加⼊相应VLAN
1. tarenasw-3L (config)#vlan 2 //vlan1是默认VLAN,不需创建
2. tarenasw-3L (config-vlan)#vlan 3
3. tarenasw-3L (config-vlan)#exit
4. tarenasw-3L (config)#interface f0/1
5. tarenasw-3L (config-if)#switchport mode access
6. tarenasw-3L (config-if)#switchport access vlan 1
7. tarenasw-3L (config-if)#interface f0/2
8. tarenasw-3L (config-if)#switchport mode access
9. tarenasw-3L (config-if)#switchport access vlan 2
10. tarenasw-3L (config-if)#interface f0/3
11. tarenasw-3L (config-if)#switchport mode access
12. tarenasw-3L (config-if)#switchport access vlan 3
步骤⼆:查看划分完的VLAN信息
VLAN1是默认VLAN,不需单独创建,也不能改名。所有端⼝默认都在VLAN1中。
1. tarenasw-2L#show vlan
2. VLAN Name Status Ports
3. ---- ----------------------- --------- ---------------------
4. 1 default active Fa0/1, Fa0/4, Fa0/5, Fa0/6
5. Fa0/7, Fa0/8, Fa0/9, Fa0/10
6. Fa0/11, Fa0/12, Fa0/13, Fa0/14
7. Fa0/15, Fa0/16, Fa0/17, Fa0/18
8. Fa0/19, Fa0/20, Fa0/21, Fa0/22
9. Fa0/23, Fa0/24, Gig1/1, Gig1/2
10. 2 vlan0002 active Fa0/2
11. 3 vlan0003 active Fa0/3
步骤三:为vlan1、vlan2、vlan3分别设置管理IP并开启三层交换机路由功能
1. tarenasw-3L #enable
2. tarenasw-3L #configure terminal
3. tarenasw-3L (config)#ip routing //开启三层交换机路由功能
4. tarenasw-3L (config)#interface vlan 1
5. tarenasw-3L (config-if)#ip address 192.168.1.254 255.255.255.0
6. tarenasw-3L (config-if)#no shutdown
7. tarenasw-3L (config-if)#exit
8. tarenasw-3L (config)#interface vlan 2
9. tarenasw-3L (config-if)#ip address 192.168.2.254 255.255.255.0
10. tarenasw-3L (config-if)#no shutdown
11. tarenasw-3L (config-if)#exit
12. tarenasw-3L (config)#interface vlan 3
13. tarenasw-3L (config-if)#ip address 192.168.3.254 255.255.255.0
14. tarenasw-3L (config-if)#no shutdown
步骤四:给客户端配置IP地址并测试⽹络连通性如图-2图-3所⽰
图-2
图-3
在PC1三上测试⽹络连通性
1. PC1>ping 19
2.168.
3.1
2.
3. Pinging 192.168.3.1 with 32 bytes of data:
4.
5. Reply from 192.168.3.1: bytes=32 time=11ms TTL=128
6. Reply from 192.168.3.1: bytes=32 time=1ms TTL=128
7. Reply from 192.168.3.1: bytes=32 time=1ms TTL=128
8. Reply from 192.168.3.1: bytes=32 time=4ms TTL=128
9.
10. Ping statistics for 192.168.3.1:
11. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
12. Approximate round trip times in milli-seconds:
13. Minimum = 1ms, Maximum = 11ms, Average = 4ms
2 案例2:多交换机vlan间通信
2.1 问题
三层交换机将接⼊层交换机汇聚到⼀起后还需实现了多交换机间不同VLAN的通信。
2.2 ⽅案
三层交换机连接其他交换机的链路需配置为中继链路,三层交换机接⼝配置trunk模式需先封装,sw1规划vlan1、vlan2、vlan3,Sw2规划vlan4、vlan5并按图-4给相应vlan配置对应⽹段的IP。
⽹络的拓扑结构如图-4所⽰:
图-4
2.3 步骤
实现此案例需要按照如下步骤进⾏。
步骤⼀:配置三层交换机
1)三层交换机创建vlan并配置vlan的虚端⼝IP并开启路由功能
1. Switch>enable
2. Switch#configure terminal
3. Switch(config)#vlan 2
4. Switch(config-vlan)#vlan 3
5. Switch(config-vlan)#vlan 4
6. Switch(config-vlan)#vlan 5
7. Switch(config)#interface vlan 1
8. Switch(config-if)#ip address 192.168.1.254 255.255.255.0
9. Switch(config-if)#no shutdown
10. Switch(config)#interface vlan 2
11. Switch(config-if)#ip address 192.168.2.254 255.255.255.0
12. Switch(config-if)#no shutdown
13. Switch(config)#interface vlan 3
14. Switch(config-if)#ip address 192.168.3.254 255.255.255.0
15. Switch(config-if)#no shutdown
16. Switch(config)#interface vlan 4
17. Switch(config-if)#ip address 192.168.4.254 255.255.255.0
18. Switch(config-if)#no shutdown
19. Switch(config)#interface vlan 5
20. Switch(config-if)#ip address 192.168.5.254 255.255.255.0
21. Switch(config-if)#no shutdown
22. Switch(config)#ip routing //开启路由功能
2)三层交换的Fa0/23、Fa0/24设置为中继链路模式
1. Switch(config)#interface range f0/23-24
2. Switch (config-if-range)#switchport trunk encapsulation dot1q
3. Switch (config-if-range)#switchport mode trunk
步骤⼆:配置⼆层交换机
1)Sw1创建vlan2、 vlan3并将端⼝加⼊vlan
1. Sw1(config)#vlan 2
2. Sw1(config-vlan)#vlan 3
3. Sw1(config)#interface fastEthernet 0/2
4. Sw1(config-if)#switchport access vlan 2
5. Sw1(config)#interface fastEthernet 0/3
6. Sw1(config-if)#switchport access vlan 3
7. Sw1(config)#interface fastEthernet 0/5
8. Sw1(config-if)#switchport mode trunk //连接三层交换机的接⼝配置为trunk模式2)Sw2创建vlan4、 vlan5并将端⼝加⼊vlan
1. Sw2(config)#vlan 4
2. Sw2(config-vlan)#vlan 5
3. Sw2(config)#interface fastEthernet 0/1
4. Sw2(config-if)#switchport access vlan 4
5. Sw2(config)#interface f0/2
6. Sw2(config-if)#switchport access vlan 5
步骤三:按图-4配置IP并测试⽹络的连通性
1. PC>ipconfig
2. FastEthernet0 Connection:(default port)
3. Link-local .: FE80::2D0:D3FF:FE2E:5D25
4. : 192.168.1.1
5. : 255.255.255.0
6. : 192.168.1.254
7. PC>ping 192.168.4.1
8. Pinging 192.168.4.1 with 32 bytes of data:
9. Reply from 192.168.4.1: bytes=32 time=0ms TTL=127
10. Reply from 192.168.4.1: bytes=32 time=0ms TTL=127
11. Reply from 192.168.4.1: bytes=32 time=0ms TTL=127
12. Reply from 192.168.4.1: bytes=32 time=0ms TTL=127
13. Ping statistics for 192.168.4.1:
14. Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
15. Approximate round trip times in milli-seconds:
16. Minimum = 0ms, Maximum = 0ms, Average = 0ms
17. PC>ping 192.168.5.1
18. Pinging 192.168.5.1 with 32 bytes of data:
19. Reply from 192.168.5.1: bytes=32 time=0ms TTL=127
20. Reply from 192.168.5.1: bytes=32 time=0ms TTL=127
21. Reply from 192.168.5.1: bytes=32 time=0ms TTL=127
22. Reply from 192.168.5.1: bytes=32 time=0ms TTL=127
23. Ping statistics for 192.168.5.1:
24. Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
25. Approximate round trip times in milli-seconds:
26. Minimum = 0ms, Maximum = 0ms, Average = 0ms
3 案例3:三层交换配置路由
3.1 问题
三层交换机实现了VLAN间互通后,还要与其他⽹络进⾏通信,这样就需要有相关的路由机制。
交换接⼝配置为三层接⼝实现路由间通信
3.2 ⽅案
三层交换机既然具有三层功能,也就可以实现与路由器相似的配置。既可以把交换接⼝配置为三层接⼝,也可以在其上配置静态、动态路由。通过对三层交换机的路由配置,实现VLAN与其他⽹络的互通。
⽹络的拓扑结构如图-5所⽰:
图-5
3.3 步骤
实现此案例需要按照如下步骤进⾏。
步骤⼀:多交换机vlan通信与案例2完全⼀致,不再赘述
步骤⼆:将三层交换的Fa0/6⼝配置为三层路由端⼝,并配置IP地址
三层交换机的物理端⼝默认是⼆层端⼝,只具有⼆层特性,不能配置IP地址。把⼆层端⼝配置为三层端⼝后,该端⼝就具备路由功能了,可以配置IP地址,但同时也就关闭了其⼆层特性,⽐如不能把三层端⼝加⼊VLAN。
⼆层端⼝(交换机上的端⼝默认都是⼆层端⼝)默认是激活状态,那些没有使⽤到的端⼝为了安全应该⼿⼯将其禁⽤(shutdown);⽽ 三层端⼝(路由器上的端⼝或是三层交换机上被配置成路由端⼝的端⼝)默认是禁⽤状态,在使⽤之前务必要将其激活(no shutdown)。
1. Switch(config)#interface f0/6
2. Switch(config-if)#no switchport
3. Switch(config-if)#ip address 192.168.6.1 255.255.255.0
4. Switch(config-if)#no shutdown
步骤三:配置路由器的端⼝IP地址
1. Switch(config)#interface f0/0
2. Switch(config-if)#ip address 192.168.6.2 255.255.255.0
3. Switch(config-if)#no shutdown汇聚路由器
4. Switch(config-if)#interface f0/1
5. Switch(config-if)#ip address 192.168.7.254 255.255.255.0
6. Switch(config-if)#no shutdown
步骤四:在三层交换机上配置静态路由,以便VLAN内主机可以与外界⽹络互联
1. Switch(config)#ip route 19
2.168.7.0 255.255.255.0 192.168.6.2
2. Switch(config)#exit
3. Switch#show ip route
4. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
5. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
6. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
7. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
8. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
9. * - candidate default, U - per-user static route, o - ODR
10. P - periodic downloaded static route
11.
12. Gateway of last resort is not set
13.
14. C 192.168.1.0/24 is directly connected, Vlan1
15. C 192.168.2.0/24 is directly connected, Vlan2

本文发布于:2024-09-21 07:59:03,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/3/370933.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:配置   交换机   路由   交换   实现   功能   步骤   技术
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议