多层交换机静态路由实验

更新时间:2023-06-06 07:12:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

多层交换机静态路由实验

一、 实验目的

1、 理解三层交换机进行路由的原理和具体实现拓扑; 2、 理解三层交换机静态路由的配置方法;

二、 应用环境

当两台三层交换机级联时,为了保证每台交换机上所连接的网段可以和另一台交换机上

连接的网段互相通信,最简单的方法就是设置静态路由。

三、 实验设备

1、 DCRS-7604(或6804)交换机1台 2、 DCRS-5526S交换机1台 3、 PC机2-4台

4、 Console线1-2根 5、 直通网线2-4根

四、 实验拓扑

五、 实验要求

1、 在交换机A和交换机B上分别划分基于端口的VLAN:

2、 交换机A和B通过的24口级联。

3、 配置交换机A和B各VLAN虚拟接口的IP地址分别如下表所示:

4、 PC1-PC4的网络设置为:

5、 验证:

没有静态路由之前:

PC1与PC2,PC3与PC4可以互通。 PC1、PC2与PC3、PC4不通。 配置静态路由之后:

四台PC之间都可以互通。

若实验结果和理论相符,则本实验完成。

六、 实验步骤

第一步:交换机全部恢复出厂设置,配置交换机的VLAN信息 交换机A:

DCRS-7604#conf

DCRS-7604(Config)#vlan 10

DCRS-7604(Config-Vlan10)#switchport interface ethernet 1/1-8 Set the port Ethernet1/1 access vlan 10 successfully Set the port Ethernet1/2 access vlan 10 successfully Set the port Ethernet1/3 access vlan 10 successfully Set the port Ethernet1/4 access vlan 10 successfully Set the port Ethernet1/5 access vlan 10 successfully Set the port Ethernet1/6 access vlan 10 successfully Set the port Ethernet1/7 access vlan 10 successfully Set the port Ethernet1/8 access vlan 10 successfully DCRS-7604(Config-Vlan10)#exit DCRS-7604(Config)#vlan 20

DCRS-7604(Config-Vlan20)#switchport interface ethernet 1/9-16 Set the port Ethernet1/9 access vlan 20 successfully Set the port Ethernet1/10 access vlan 20 successfully Set the port Ethernet1/11 access vlan 20 successfully Set the port Ethernet1/12 access vlan 20 successfully Set the port Ethernet1/13 access vlan 20 successfully Set the port Ethernet1/14 access vlan 20 successfully Set the port Ethernet1/15 access vlan 20 successfully Set the port Ethernet1/16 access vlan 20 successfully DCRS-7604(Config-Vlan20)#exit

DCRS-7604(Config)#vlan 100

DCRS-7604(Config-Vlan100)#switchport interface ethernet 1/24 Set the port Ethernet1/24 access vlan 100 successfully DCRS-7604(Config-Vlan100)#exit DCRS-7604(Config)# 验证配置:

DCRS-7604#show vlan

VLAN Name Type Media Ports

--------------------------------------------------------------------------- 1 default Static ENET Ethernet1/17 Ethernet1/18 Ethernet1/19 Ethernet1/20 Ethernet1/21 Ethernet1/22 Ethernet1/23 Ethernet1/25 Ethernet1/26 Ethernet1/27 Ethernet1/28

10 VLAN0010 Static ENET Ethernet1/1 Ethernet1/2 Ethernet1/3 Ethernet1/4 Ethernet1/5 Ethernet1/6 Ethernet1/7 Ethernet1/8 20 VLAN0020 Static ENET Ethernet1/9 Ethernet1/10 Ethernet1/11 Ethernet1/12 Ethernet1/13 Ethernet1/14 Ethernet1/15 Ethernet1/16 100 VLAN0100 Static ENET Ethernet1/24 DCRS-7604#

交换机B:

DCRS-5526S(Config)#vlan 30

DCRS-5526S(Config-Vlan30)#switchport interface ethernet 0/0/1-8 Set the port Ethernet0/0/1 access vlan 30 successfully Set the port Ethernet0/0/2 access vlan 30 successfully Set the port Ethernet0/0/3 access vlan 30 successfully Set the port Ethernet0/0/4 access vlan 30 successfully Set the port Ethernet0/0/5 access vlan 30 successfully Set the port Ethernet0/0/6 access vlan 30 successfully Set the port Ethernet0/0/7 access vlan 30 successfully Set the port Ethernet0/0/8 access vlan 30 successfully DCRS-5526S(Config-Vlan30)#exit DCRS-5526S(Config)#vlan 40

DCRS-5526S(Config-Vlan40)#switchport interface ethernet 0/0/9-16 Set the port Ethernet0/0/9 access vlan 40 successfully Set the port Ethernet0/0/10 access vlan 40 successfully Set the port Ethernet0/0/11 access vlan 40 successfully Set the port Ethernet0/0/12 access vlan 40 successfully Set the port Ethernet0/0/13 access vlan 40 successfully Set the port Ethernet0/0/14 access vlan 40 successfully Set the port Ethernet0/0/15 access vlan 40 successfully Set the port Ethernet0/0/16 access vlan 40 successfully DCRS-5526S(Config-Vlan40)#exit DCRS-5526S(Config)#vlan 101

DCRS-5526S(Config-Vlan101)#switchport interface ethernet 0/0/24

Set the port Ethernet0/0/24 access vlan 101 successfully DCRS-5526S(Config-Vlan101)#exit DCRS-5526S(Config)# 验证配置:

DCRS-5526S#show vlan

VLAN Name Type Media Ports

----------------------------------- --------------------------------------- 1 default Static ENET Ethernet0/0/17 Ethernet0/0/18 Ethernet0/0/19 Ethernet0/0/20 Ethernet0/0/21 Ethernet0/0/22 Ethernet0/0/23

30 VLAN0030 Static ENET Ethernet0/0/1 Ethernet0/0/2 Ethernet0/0/3 Ethernet0/0/4 Ethernet0/0/5 Ethernet0/0/6 Ethernet0/0/7 Ethernet0/0/8 40 VLAN0040 Static ENET Ethernet0/0/9 Ethernet0/0/10 Ethernet0/0/11 Ethernet0/0/12 Ethernet0/0/13 Ethernet0/0/14 Ethernet0/0/15 Ethernet0/0/16 101 VLAN0101 Static ENET Ethernet0/0/24 DCRS-5526S#

第二步:配置交换机各vlan虚接口的IP地址

交换机A:

DCRS-7604(Config)#int vlan 10

DCRS-7604(Config-If-Vlan10)#ip address 192.168.10.1 255.255.255.0 DCRS-7604(Config-If-Vlan10)#no shut DCRS-7604(Config-If-Vlan10)#exit DCRS-7604(Config)#int vlan 20

DCRS-7604(Config-If-Vlan20)#ip address 192.168.20.1 255.255.255.0 DCRS-7604(Config-If-Vlan20)#no shut DCRS-7604(Config-If-Vlan20)#exit DCRS-7604(Config)#int vlan 100

DCRS-7604(Config-If-Vlan100)#ip address 192.168.100.1 255.255.255.0 DCRS-7604(Config-If-Vlan100)#no shut DCRS-7604(Config-If-Vlan100)# DCRS-7604(Config-If-Vlan100)#exit DCRS-7604(Config)#

交换机B:

DCRS-5526S(Config)#int vlan 30

DCRS-5526S(Config-If-Vlan30)#ip address 192.168.30.1 255.255.255.0 DCRS-5526S(Config-If-Vlan30)#no shut DCRS-5526S(Config-If-Vlan30)#exit DCRS-5526S(Config)#interface vlan 40

DCRS-5526S(Config-If-Vlan40)#ip address 192.168.40.1 255.255.255.0 DCRS-5526S(Config-If-Vlan40)#exit DCRS-5526S(Config)#int vlan 101

DCRS-5526S(Config-If-Vlan101)#ip address 192.168.100.2 255.255.255.0 DCRS-5526S(Config-If-Vlan101)#exit DCRS-5526S(Config)#

第三步:配置各PC的IP地址,注意配置网关

查看路由表,进一步分析上一步的现象原因。 交换机A:

DCRS-7604#show ip route

Total route items is 3, the matched route items is 3

Codes: C - connected, S - static, R - RIP derived, O - OSPF derived A - OSPF ASE, B - BGP derived, D - DVMRP derived

Destination Mask Nexthop Interface Preference C 192.168.10.0 255.255.255.0 0.0.0.0 Vlan10 0 C 192.168.20.0 255.255.255.0 0.0.0.0 Vlan20 0 C 192.168.100.0 255.255.255.0 0.0.0.0 Vlan100 0 DCRS-7604#

(C代表直连的网段)

交换机B:

DCRS-5526S#show ip route

Total route items is 3, the matched route items is 3

Codes: C - connected, S - static, R - RIP derived, O - OSPF derived A - OSPF ASE, B - BGP derived, D - DVMRP derived

Destination Mask Nexthop Interface Preference C 192.168.30.0 255.255.255.0 0.0.0.0 Vlan30 0 C 192.168.40.0 255.255.255.0 0.0.0.0 Vlan40 0 C 192.168.100.0 255.255.255.0 0.0.0.0 Vlan101 0 DCRS-5526S#

第五步:配置静态路由

交换机A:

DCRS-7604(Config)#ip route 192.168.30.0 255.255.255.0 192.168.100.2 DCRS-7604(Config)#ip route 192.168.40.0 255.255.255.0 192.168.100.2 验证配置:

DCRS-7604#show ip route

Total route items is 5, the matched route items is 5

Codes: C - connected, S - static, R - RIP derived, O - OSPF derived A - OSPF ASE, B - BGP derived, D - DVMRP derived

Destination Mask Nexthop Interface Preference C 192.168.10.0 255.255.255.0 0.0.0.0 Vlan10 0 C 192.168.20.0 255.255.255.0 0.0.0.0 Vlan20 0 S 192.168.30.0 255.255.255.0 192.168.100.2 Vlan100 1 S 192.168.40.0 255.255.255.0 192.168.100.2 Vlan100 1 C 192.168.100.0 255.255.255.0 0.0.0.0 Vlan100 0 DCRS-7604#

(S代表静态配置的网段)

交换机B:

DCRS-5526S(Config)#ip route 192.168.10.0 255.255.255.0 192.168.100.1 DCRS-5526S(Config)#ip route 192.168.20.0 255.255.255.0 192.168.100.1 验证配置:

DCRS-5526S#show ip route

Total route items is 5, the matched route items is 5

Codes: C - connected, S - static, R - RIP derived, O - OSPF derived A - OSPF ASE, B - BGP derived, D - DVMRP derived

Destination Mask Nexthop Interface Preference S 192.168.10.0 255.255.255.0 192.168.100.1 Vlan101 1 S 192.168.20.0 255.255.255.0 192.168.100.1 Vlan101 1 C 192.168.30.0 255.255.255.0 0.0.0.0 Vlan30 0 C 192.168.40.0 255.255.255.0 0.0.0.0 Vlan40 0 C 192.168.100.0 255.255.255.0 0.0.0.0 Vlan101 0 DCRS-5526S#

七、 注意事项和排错

1、 PC机一定要配置正确的网关,否则不能正常通信;

2、 两台交换机级联的端口可以在同一vlan,也可以在不同vlan。

八、 配置序列

九、 共同思考

1、 如果把交换机B上的vlan30改成vlan10,请问两台交换机上的vlan10是同一个VLAN么?

2、 第四步中,PC1 ping vlan101以及PC1 ping PC3都不通,其原因各是什么?

十、 课后练习

1、 在交换机A和交换机B上分别划分基于端口的VLAN:

2、 交换机

A和B通过的24口级联。

3、 配置交换机A和B各VLAN虚拟接口的IP地址分别如下表所示:

4、 PC1-PC4的网络设置为:

5、 要求PC之间都可以通信

十一、 相关配置命令详解

ip route

命令:ip route <ip_address> <mask> <gateway> [<preference>]

no ip route <ip_address> <mask> <gateway> [<preference>] 功能:配置静态路由;本命令的no操作为删除静态路由。

参数:<ip_address>和<mask>分别为目的IP地址和子网掩码,点分十进制格式; <gateway>为下一跳的IP地址,点分十进制格式;<preference>为路由优先级,取值范围为1~255,preference的值越小优先级越高。

缺省情况:DCRS-7604三层交换机的静态路由缺省优先级为1。 命令模式:全局配置模式

使用指南:在配置静态路由的下一跳时,可采用指定路由数据包发送下一跳IP地址方式。

RIP、IBGP。 举例:

例1.添加一条静态路由。

Switch(config)#ip route 1.1.1.0 255.255.255.0 2.1.1.1 例2.添加缺省路由。

Switch(config)#ip route 0.0.0.0 0.0.0.0 2.2.2.1

show ip route

命令:show ip route [dest <destination>] [mask <destMask>] [nextHop <nextHopValue>] [protocol {connected | static | rip| ospf | ospf_ase | bgp | dvmrp}] [<vlan-id>] [preference <pref>] [count]

功能:显示路由表。

参数:<destination>为目标网络地址;<destMask>为目标网络的掩码;<nextHopValue>为下一跳IP地址;connected为直连路由;static为静态路由;rip 为RIP路由;ospf 为OSPF路由;ospf_ase 为OSPF引入的路由;bgp 为BGP路由;dvmrp 为DVMRP路由;<vlan-id> 为Vlan标识符;<pref> 为路由优先级,取值范围为0~255;count为显示IP路由表项数量信息。

命令模式:特权用户配置模式

使用指南:显示核心路由表的内容,包括:路由类型、目的网络、掩码、下一跳地址、接口等。

本文来源:https://www.bwwdw.com/article/wm11.html

Top