一、 实验目的
- 理解路由表
- 掌握静态路由的配置
二、 应用环境
- 在小规模环境里,静态路由是最佳的选择
- 静态路由开销小,但不灵活,适用于相对稳定的网络
三、 实验设备
1、DCR-2655 三台 2、网线(交叉线) 四条
四、 实验拓扑
五、实验要求
六、 实验步骤
第一步:按照上方配置表配置所有接口的 IP 地址,保证所有接口全部是 up 状态,测试连通性如 R1 配置:
Router_config#hostname R1
R1_config#
R1_config#interface gigaEthernet 0/3
R1_config_g0/3#ip address 192.168.0.1 255.255.255.0
R1_config_g0/3#exit
R1_config#interface gigaEthernet 0/4
R1_config_g0/4#ip address 192.168.1.1 255.255.255.0
R1_config_g0/4#exit
R2 、R3 配置如上
第二步:查看 R1 的路由表
R1#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
C 192.168.0.0/24 is directly connected, GigaEthernet0/3 !直连的路由
C 192.168.1.0/24 is directly connected, GigaEthernet0/4
第三步:查看 R2 的路由表
R2_config#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
C 192.168.1.0/24 is directly connected, GigaEthernet0/4
C 192.168.2.0/24 is directly connected, GigaEthernet0/3
第四步:查看 R3 的路由表
R3#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
C 192.168.2.0/24 is directly connected, GigaEthernet0/3
C 192.168.3.0/24 is directly connected, GigaEthernet0/4
第五步:在 R1 上 PING R3
R1#ping 192.168.2.2
PING 192.168.2.2 (192.168.2.2): 56 data bytes
.....
--- 192.168.2.2 ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss !不通
第六步:在 R1 上配置静态路由
R1#config
R1_config#ip route 192.168.2.0 255.255.255.0 192.168.1.2 !配置目标网段和下一跳
R1_config#ip route 192.168.3.0 255.255.255.0 192.168.1.2
第七步:查看路由表
R1#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
C 192.168.0.0/24 is directly connected, GigaEthernet0/3
C 192.168.1.0/24 is directly connected, GigaEthernet0/4
S 192.168.2.0/24 [1,0] via 192.168.1.2(onGigaEthernet0/4)
!注意静态路由 AD 是 1
S 192.168.3.0/24 [1,0] via 192.168.1.2(on GigaEthernet0/4)
第八步:配置 R2 的静态路由并查看路由表
R2#config
R2_config#ip route 192.168.0.0 255.255.255.0 192.168.1.1
R2_config#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R2_config#
R2#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
S 192.168.0.0/24 [1,0] via 192.168.1.1(on GigaEthernet0/4)
C 192.168.1.0/24 is directly connected, GigaEthernet0/4
C 192.168.2.0/24 is directly connected, GigaEthernet0/3
S 192.168.3.0/24 [1,0] via 192.168.2.2(onGigaEthernet0/3)
第九步:配置 R3 的静态路由并查看路由表
R3#config
R3_config#ip route 192.168.0.0 255.255.0.0 192.168.2.1 !采用超网的方法
R3_config#
R3#show ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - BEIGRP, DEX - external BEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type, L1 - IS-IS level-1, L2 - IS-IS level-2
VRF ID: 0
S 192.168.0.0/16 [1,0] via 192.168.2.1(on GigaEthernet0/3) !采用超网的方法
C 192.168.2.0/24 is directly connected, GigaEthernet0/3
C 192.168.3.0/24 is directly connected, GigaEthernet0/4
第十步:测试
R3#ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1): 56 data bytes
!!!!! !成功
--- 192.168.0.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms
七、注意事项和排错
- 非直连的网段都要配置路由
- 使用静态路由时,要进行双向配置,以做到数据包双向寻址
- 以太网接口要接主机或交换机才能 up
- 只有动态路由的条目才能被缓冲,静态路由是不会被缓冲的
八、相关配置命令详解
ip route 监控状态下使用本命令 ip route 可以指定缺省网关。 ip route default gw_ip_addr 缺省 :无 命令模式: 监控状态 使用说明 :下一跳可以是具体的 ip 地址(该 ip 与路由器某接口地址处于相同网段),也可以是本地端口名称(常用于拨号线路)
示例
monitor#ip route default 192.168.1.3
|