思科设备静态路由配置
1.静态路由的工作原理及应用场景
2.默认路由的应用场景及配置方法
3.静态浮动路由的应用场景及配置方法
实验拓扑图正常情况下c1和c2通过交换机直连就可以通,但是c1和c2和c3都通信不了,因为
它们不在一个网段。需要在R1上面设置两个口f0/0和f0/1 ip ,即c1 c2 和c3的网关,这样c1才能Ping通c3.数据包c1->sw1-》f0/0 查看R1路由表(给R1路由器配置ip地址记得加ip add ,配置完ip 记得no shut启动,路由器互相ping端口的时候记得前面加do ping,R2(config-if)#do ping 192.168.2.1)
配置好后查看R1路由表R1#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
实验拓扑2c1 ping 192.168.2.2不通行走路线
c1 pingR2f0/0 c1会先到R1,R1会查看路由表,有到192.168.2.2的网段
查看R2是否收到pc1发过来的数据命令
R2#debug ip icmp
ICMP packet debugging is on
R2#
*Mar 1 00:39:22.971: ICMP: echo reply sent, src 192.168.2.2, dst 192.168.1.20
R2#show ip route发现左侧和右侧f0/0和f0/1怎么走,但是没有到达192.168.1.1段怎么走,它会将c1发过来的数据包丢弃
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
解决c1 ping 192.168.2.2通行语法:在R2上加入静态路由命令
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R2(config)#ip route 目标ip 目标掩码 中转IP
同理,c1 ping 192.168.3.1不通,需要在R1上加入静态路由
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R1#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
S 192.168.3.0/24 [1/0] via 192.168.2.2(s静态)
此时c1 ping 192.168.3.0 ping通
现实中R1不可能会添加很多静态路由告诉路由器如何走通,此时需要用到默认路由
R3(config)#ip route 0.0.0.0 (任意网段)0.0.0.0(任意掩码) 192.168.3.1(R3上添加默认路由,不管到达哪个路由,都通过192.168.3.1行走)R1,R3可以用到默认路由,R2多个出口的路由器,不能用到默认路由,只能用到静态路由.
R3#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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 192.168.3.1 to network 0.0.0.0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 192.168.3.1(s*表示默认路由)
R1#write保存R1配置文件
浮动路由拓扑图11.R1->R2 或者2.R1->R3->R2 默认走1,如果R1->R2线路出故障,走2