1.靜態(tài)路由的工作原理及應(yīng)用場景
2.默認(rèn)路由的應(yīng)用場景及配置方法
3.靜態(tài)浮動路由的應(yīng)用場景及配置方法
正常情況下c1和c2通過交換機(jī)直連就可以通,但是c1和c2和c3都通信不了黎做,因?yàn)?/p>
它們不在一個網(wǎng)段蜂嗽。需要在R1上面設(shè)置兩個口f0/0和f0/1 ip ,即c1 c2 和c3的網(wǎng)關(guān)马绝,這樣c1才能Ping通c3.數(shù)據(jù)包c(diǎn)1->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
c1 ping 192.168.2.2不通行走路線
c1 pingR2f0/0 c1會先到R1,R1會查看路由表源请,有到192.168.2.2的網(wǎng)段
查看R2是否收到pc1發(fā)過來的數(shù)據(jù)命令
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發(fā)現(xiàn)左側(cè)和右側(cè)f0/0和f0/1怎么走,但是沒有到達(dá)192.168.1.1段怎么走彻况,它會將c1發(fā)過來的數(shù)據(jù)包丟棄
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上加入靜態(tài)路由命令
R2(config)#ip route? 192.168.1.0 255.255.255.0 192.168.2.1
R2(config)#ip route 目標(biāo)ip 目標(biāo)掩碼? 中轉(zhuǎn)IP
同理谁尸,c1 ping 192.168.3.1不通,需要在R1上加入靜態(tài)路由
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靜態(tài))
此時c1 ping 192.168.3.0 ping通
現(xiàn)實(shí)中R1不可能會添加很多靜態(tài)路由告訴路由器如何走通纽甘,此時需要用到默認(rèn)路由
R3(config)#ip route 0.0.0.0 (任意網(wǎng)段)0.0.0.0(任意掩碼) 192.168.3.1(R3上添加默認(rèn)路由良蛮,不管到達(dá)哪個路由,都通過192.168.3.1行走)R1悍赢,R3可以用到默認(rèn)路由决瞳,R2多個出口的路由器货徙,不能用到默認(rèn)路由,只能用到靜態(tài)路由.
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*表示默認(rèn)路由)
R1#write保存R1配置文件
1.R1->R2 或者2.R1->R3->R2 默認(rèn)走1皮胡,如果R1->R2線路出故障痴颊,走2