1. 程式人生 > 實用技巧 >ospf在企業網中的應用

ospf在企業網中的應用

ospf在企業網路中的應用

ospf簡介:Ospf是open shortest pash firet ,是開放的最短路徑優先協議 ,是基於鏈路的鏈路狀態協議,屬於高階路由協議。

特點 1 觸發更新。當網路中拓撲結構發生改變是,而觸發更新,但是,觸發更新只發送增量。每30分鐘檢查一次更新

2:釋出鏈路狀態,只發布增量

3:採用組播的形式傳送報文,兩個組播地址是224.0.0.5和224.0.0.6

4:metrci:從頻寬、延遲、負載、可靠度和mtu來計算metrci。計算方法:到達目標的所有出口的cost值相加,cost值為100/頻寬
5:適應範圍:支援各種規模的網路,最多可支援幾千臺路由器。
6:負載均衡:支援到同一目的的地址的多條等值路由,只支援等代價的。只有cisco裝置支援非等代價負載均衡

7:收斂速度:收斂速度快,在網路的拓撲結構發生變化後立即傳送更新報文,在自治域裡快速同步變化
8 :不會形成路由環路:是高階路由協議不會形成路由環。Ospf根據收到的鏈路狀體用最短路徑樹來計算路由,從演算法上本身保證了 不會形成路由環
9:支援驗證:支援基於藉口的報文驗證以保證路由計算的安全性
10:三張表格:1)鄰居表格 2)鏈路狀態資料庫(lsdb) 3)路由表
11:支援可變長子網掩碼以及子網不連續
12:體系化路由分割槽:區域劃分,允許自治系統的網路被劃分成分割槽來管理,區域間傳送的路由資訊被進一步抽象,從而減少了佔用的網路頻寬。區域劃分為瞭解決網路的不穩定造成的路由資訊一直修改以及lsdb條目比較多。


單區域ospf原理

1. 處於同一區域的路由器之間通訊,如果是廣播多路,並且有多臺路由器,他們必須首先建立鄰居關係,建立鄰居關係,是靠的傳送的hello包,hello包包括routerid,neighbors,dr ipadd,以及bdripadd。
Routera像routerb 傳送一個hello包,b受到後,知道自己有a鄰居。然後改寫自己的鄰居表格,然後應答a的hello 包。
建立鄰居關係後。就是達到第一個標誌性的狀態:two—state狀態

2.之後就必須選舉一個dr以及bdr,為了方便路由器,在路由器中選舉 一個dr,然後沒一個路由器與dr交流,dr再去通知鏈路上其他的路由器。

選舉dr與bdr是根據router priority(路由優先順序)p,p值越高就為dr次高的為bdr,
P值預設值為1,可以手動人為的改寫p值來認定dr,p值為0的無權參加選舉,(注意 若一個穩定的網路中一開始dr p值是3 ,又重新進來一個路由器p值為10,則為了網路的穩定dr不變,若dr失效,則由bdr擔當dr 只有到下一次選舉的時候p值為10 的路由器才能成為dr)

3.有了dr與bdr 然後dr首先向下邊的所有的路由器傳送自己的lsdb的描述法通過dbd包,下邊路由器受到後 改寫自己的資料鏈路資料庫(lsdb),然後應答dr,將自己的lsdb描述符給dr。若routera沒有 routerc的路由資訊,a像dr請求完整的lsdb,然後達到一樣的資料鏈路資料庫。最後當他們的資料鏈路資料庫一樣時就達到了第二個標誌性狀態:full—state

4.最後每個路由器根據自己的lsdb 利用spf計算出路由表 然後形成三張表格
Spf時一種固定的演算法 , 是路由器自己執行的

5.當網路發生變動時,a修改自己的lsdb,然後向dr傳送自己的lsdb更新,通過組播地址:224.0.0.6,dr受到後改寫自己的lsdb然後在通過組播地址224.0.0.5通知其他所有的路由器,所有路由器收到後,改寫自己的lsdb,從而達到full—state狀態點對點的鏈路,只連線兩臺路由器,沒有dr與bdr 沒有選舉過程,只通過組播224.0.0.5傳送路由資訊。

多區域網路
1.當今網路越來越大,路由器數目越來越多,從而來區域劃分。
2.區域劃分的目的:減少自己的lsdb的表項,以及路由表的表項,和網路的不穩定造成的而影響全域性
3.區域劃分要求,1個核心區域,也是骨幹區域 即是Area0區域,其他為預設區域 也叫標準區域,每一個標準區域必須與核心區域相連線 ,兩個標準區域不能直接連在一起
4.核心區域的選取, 1 穩定 2 速度快 3 其間路由器的數目越少越好
5.特殊的標準區域,末節區域,和完全末節區域。

多區域路由器分類

1.內部路由器: 如果一臺路由器上所有啟用了OSPF的介面都在同一區域,那麼這臺路由器就是內部路由器。

2.骨幹路由器:骨幹路由器是指至少有一個啟用了OSPF的介面是和骨幹區域(Area 0)相連的路由器。一臺骨幹路由器也可以同時是ABR或ASBR,如上圖中的R2和R3。如果一臺路由器上所有的介面都屬於Area 0,那麼這臺路由器也是一臺內部路由器。

3.區域邊界路由器 (abr) 區域界路由器是指連線一個或者多個區域到骨幹區域的路由器。區域邊界路由器必須至少有一個介面屬於骨幹區域。區域邊界路由器為每一個與之相連的區域維護一份鏈路狀態資料庫,因此區域邊界路由器需要比內部路由器更多的記憶體資源和更高效能的處理器

4.自治系統邊界路由器自治系統邊界路由器(ASBR)用來把從其他路由協議(如BGP、EIGRP等)學習到的路由以路由重分發的方式注入到OSPF程序中,從而使得整個OSPF域內的路由器都可以學習到這些路由(除了末梢區域內的路由器)。一臺ASBR可以是OSPF域內非末梢區域的任何路由器,它可以是內部路由器、區域邊界路由器、骨幹路由器。

路由歸納必須在abr路由器上,
若 area1與area0相連,area2不能與area0 相連,只能與area1連線,但是違背區域劃分要求,這樣就把area1看成是一條鏈路 看成通過這條鏈路直接連在area0上

非廣播多路

訪問網路NBMA網路,如X.25、幀中繼、ATM等,可以同時連線兩臺以上的路由器,但是這種網路沒有廣播資料包的能力。一臺處於NBMA網路上的路由器傳送的組播/廣播資料包將不能被其他與之相連的路由器收到。在NBMA網路上需要選舉DR和BDR,並且所有的OSPF資料包都是單播發送的

案例

router1配置:

Router>en
Router#conf t
Router(config)#hostname r1
r1(config)#
r1(config)#line c 0
r1(config-line)#no exec-timeout
r1(config-line)#logging synchronous
r1(config-line)#exit
r1(config)#
r1(config)#int f0/0
r1(config-if)#no ip add
r1(config-if)#ip add 192.168.1.1 255.255.255.0 配置ip地址
r1(config-if)#no sh
r1(config)#int s 1/0
r1(config-if)#ip add 192.168.2.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#exit
r1(config)#router ospf 100 開啟ospf
r1(config-router)#
r1(config-router)#network 192.168.1.0 ? 配置反掩碼
A.B.C.D OSPF wild card bits
r1(config-router)#network 192.168.1.0 0.0.0.255 ? 反掩碼=255.255.255.255—當前掩碼
area Set the OSPF area ID
r1(config-router)#network 192.168.1.0 0.0.0.255 area ?
<0-4294967295> OSPF area ID as a decimal value
A.B.C.D OSPF area ID in IP address format
r1(config-router)#network 192.168.1.0 0.0.0.255 area 1 ?
<cr>
r1(config-router)#network 192.168.1.0 0.0.0.255 area 1

r1(config-router)#network 192.168.2.0 0.0.0.255 area 1 配置ospf介面網段以及區域area1
r1(config-router)#int s 1/0
r1(config-if)#exit
r1(config)#

router2配置:

Router>en
Router#conf t
Router(config)#hostname r2
r2(config)#line c 0
r2(config-line)#no exec-t
r2(config-line)#no exec-timeout
r2(config-line)#logging synchronous
r2(config-line)#exit
r2(config)#
r2(config)#int s1/0
r2(config-if)#ip add 192.168.2.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int s 1/1
r2(config-if)#ip add 192.168.3.1 255.255.255.0
r2(config-if)#no sh
r2(config-if)#exit
r2(config)#
r2(config)#int f0/0
r2(config-if)#no ip add
r2(config-if)#ip add 192.168.6.1 255.255.255.0
r2(config-if)#no sh
r2(config-if)#exit
r2(config)#
r2(config)#router ospf 100
r2(config-router)#network 192.168.2.0 0.0.0.255 a 1
r2(config-router)#^Z
r2#
r2#conf t
r2(config)#
r2(config)#router rip
r2(config-router)#net 192.168.6.0
r2(config-router)#^Z
r2#
r2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r2(config)#int f 0/0
r2(config-if)#no ip add
r2(config-if)#int s1/2
r2(config-if)#ip add 192.168.6.1 255.255.255.0
r2(config-if)#no sh
r2(config-if)#exit
r2(config)#
r2(config)#router ospf 100
r2(config-router)#redistribute rip m
r2(config-router)#redistribute rip metric ?
<0-16777214> OSPF default metric
r2(config-router)#redistribute rip metric 2 將rip重分發給ospf
r2(config-router)#exit
r2(config)#router rip
r2(config-router)#redistribute ospf 100 ?
match Redistribution of OSPF routes
metric Metric for redistributed routes
route-map Route map reference
vrf ××× Routing/Forwarding Instance
<cr>

r2(config-router)#redistribute ospf 100 將ospf重分發給rip
r2(config-router)#^Z
r2#
r2#show run
Building configuration...

Current configuration : 904 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r2
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.2.2 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.3.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
ip address 192.168.6.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 100
log-adjacency-changes
redistribute rip metric 2
network 192.168.2.0 0.0.0.255 area 1
network 192.168.3.0 0.0.0.255 area 0
default-information originate
!
router rip
redistribute ospf 100
network 192.168.6.0
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end
r2#conf t
r2(config)#
r2(config)#router rip
r2(config-router)#red ?
bgp Border Gateway Protocol (BGP)
connected Connected
egp Exterior Gateway Protocol (EGP)
eigrp Enhanced Interior Gateway Routing Protocol (EIGRP)
igrp Interior Gateway Routing Protocol (IGRP)
isis ISO IS-IS
iso-igrp IGRP for OSI networks
metric Metric for redistributed routes
mobile Mobile routes
odr On Demand stub Routes
ospf Open Shortest Path First (OSPF)
rip Routing Information Protocol (RIP)
route-map Route map reference
static Static routes
<cr>
r2(config-router)#red ospf ?
<1-65535> Process ID

r2(config-router)#red ospf 100 ?
match Redistribution of OSPF routes
metric Metric for redistributed routes
route-map Route map reference
vrf ××× Routing/Forwarding Instance
<cr>

r2(config-router)#red ospf 100 met
r2(config-router)#red ospf 100 metric ?
<0-16> Default metric
transparent Transparently redistribute metric

r2(config-router)#redistribute ospf 100 metric 2

r2(config-router)#exit
r2(config)#re?
regexp resume-string
r2(config)#de?
default default-value define
r2(config)#default-?
default-value
r2(config)#router rip
r2(config-router)#
r2(config-router)#default-information o
r2(config-router)#default-information originate ?
route-map Route-map reference
<cr>

r2(config-router)#default-information originate
r2(config-router)#exit
r2(config)#^Z
r2#show ip ro
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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

O IA 192.168.4.0/24 [110/128] via 192.168.3.2, 00:20:08, Serial1/1
O IA 192.168.5.0/24 [110/129] via 192.168.3.2, 00:20:08, Serial1/1
C 192.168.6.0/24 is directly connected, Serial1/2
R 192.168.7.0/24 [120/1] via 192.168.6.2, 00:00:19, Serial1/2
O 192.168.1.0/24 [110/65] via 192.168.2.1, 00:20:08, Serial1/0
C 192.168.2.0/24 is directly connected, Serial1/0
C 192.168.3.0/24 is directly connected, Serial1/1
r2#show running-config
Building configuration...

Current configuration : 944 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r2
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.2.2 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.3.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
ip address 192.168.6.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 100
log-adjacency-changes
redistribute rip metric 2
network 192.168.2.0 0.0.0.255 area 1
network 192.168.3.0 0.0.0.255 area 0
default-information originate
!
router rip
redistribute ospf 100 metric 2
network 192.168.6.0
default-information originate
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end

r2#

router3配置:

Router>en
Router#conf t
Router(config)#hostname r3
r3(config)#line c 0
r3(config-line)#no exec-timeout
r3(config-line)#logging sy
r3(config-line)#logging synchronous
r3(config-line)#exit
r3(config)#int s1/1
r3(config-if)#ip add 192.168.3.2 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int s 1/0
r3(config-if)#ip add 192.168.4.1 255.255.255.0
r3(config-if)#no sh
r3(config-if)#exit
r3(config)#
r3(config)#router ospf 100
r3(config-router)#network 192.168.3.0 0.0.0.255 a 0
r3(config-router)#network 192.168.4.0 0.0.0.255 a 0
r3(config-router)#^Z
r3#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/67/84 ms
r3#show ip rou
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.4.0/24 is directly connected, Serial1/0
O 192.168.5.0/24 [110/65] via 192.168.4.2, 00:28:01, Serial1/0
O E2 192.168.6.0/24 [110/2] via 192.168.3.1, 00:08:40, Serial1/1
O E2 192.168.7.0/24 [110/2] via 192.168.3.1, 00:08:40, Serial1/1
O IA 192.168.1.0/24 [110/129] via 192.168.3.1, 00:11:42, Serial1/1
O IA 192.168.2.0/24 [110/128] via 192.168.3.1, 00:11:42, Serial1/1
C 192.168.3.0/24 is directly connected, Serial1/1
r3#show run
Building configuration...

Current configuration : 786 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r3
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.4.1 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.3.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 100
log-adjacency-changes
network 192.168.3.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 2
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end
r3#conf t
r3(config)#router ospf 100

r3(config-router)#int s1/0
r3(config-if)#rout?
r3(config)#exit
r3#
r3#conf t
r3(config)#router ospf 100
r3(config-router)#area 2 stub ?
no-summary Do not send summary LSA into stub area
<cr>

r3(config-router)#area 2 stub n
r3(config-router)#area 2 stub no-summary 將area變成完全末節區域
r3(config-router)#

r3#show run
Building configuration...

Current configuration : 810 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r3
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.4.1 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.3.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 100
log-adjacency-changes
area 2 stub no-summary
network 192.168.3.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 2
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end

r3# show ip rou
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.4.0/24 is directly connected, Serial1/0
O 192.168.5.0/24 [110/65] via 192.168.4.2, 00:00:49, Serial1/0
O E2 192.168.6.0/24 [110/2] via 192.168.3.1, 00:00:49, Serial1/1
O E2 192.168.7.0/24 [110/2] via 192.168.3.1, 00:00:49, Serial1/1
O IA 192.168.1.0/24 [110/129] via 192.168.3.1, 00:00:49, Serial1/1
O IA 192.168.2.0/24 [110/128] via 192.168.3.1, 00:00:49, Serial1/1
C 192.168.3.0/24 is directly connected, Serial1/1
r3#

router4配置:Router>en
Router#conf t
Router(config)#hostname r4
r4(config)#
r4(config)#line c 0
r4(config-line)#
r4(config-line)#no exec-timeout
r4(config-line)#logging synchronous
r4(config-line)#exit
r4(config)#int s1/0
r4(config-if)#ip add 192.168.4.2 255.255.255.0
r4(config-if)#no sh
r4(config-if)#int f0/0
r4(config-if)#ip add 192.168.5.1 255.255.255.0
r4(config-if)#loop
r4(config-if)#no sh
r4(config-if)#exit
r4(config)#
r4(config)#router ospf 100
r4(config-router)#network 192.168.4.0 0.0.0.255 a 2
r4(config-router)#network 192.168.5.0 0.0.0.255 a 2
r4(config-router)#^Z
r4#
r4#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 88/110/144 ms
r4#show ip rou
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.4.0/24 is directly connected, Serial1/0
C 192.168.5.0/24 is directly connected, FastEthernet0/0
O E2 192.168.6.0/24 [110/2] via 192.168.4.1, 00:16:02, Serial1/0
O E2 192.168.7.0/24 [110/2] via 192.168.4.1, 00:16:02, Serial1/0
O IA 192.168.1.0/24 [110/193] via 192.168.4.1, 00:35:24, Serial1/0
O IA 192.168.2.0/24 [110/192] via 192.168.4.1, 00:35:24, Serial1/0
O IA 192.168.3.0/24 [110/128] via 192.168.4.1, 00:35:24, Serial1/0
r4#conf t
r4(config)#router ospf 100
r4(config-router)#ar
r4(config-router)#area 2 stub no
r4(config-router)#area 2 stub no-summary 將area2變成完全末節區域
r4(config-router)#^Z
r4#
r4#show ip rou
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.4.1 to network 0.0.0.0

C 192.168.4.0/24 is directly connected, Serial1/0
C 192.168.5.0/24 is directly connected, FastEthernet0/0
O*IA 0.0.0.0/0 [110/65] via 192.168.4.1, 00:00:09, Serial1/0
r4#show run
Building configuration...

Current configuration : 820 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r4
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
ip address 192.168.5.1 255.255.255.0
loopback
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.4.2 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 100
log-adjacency-changes
area 2 stub no-summary
network 192.168.4.0 0.0.0.255 area 2
network 192.168.5.0 0.0.0.255 area 2
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end

r4#

router5配置:

Router>
Router>en
Router#conf t
Router(config)#
Router(config)#hostname r5
r5(config)#line c 0
r5(config-line)#
r5(config-line)#no exec-timeout
r5(config-line)#logging sy
r5(config-line)#exit
r5(config)#
r5(config)#int s1/0
r5(config-if)#ip add 192.168.6.2 255.255.255.0
r5(config-if)#no sh
r5(config-if)#
r5(config-if)#int s1/1
r5(config-if)#ip add 192.168.7.1 255.255.255.0
r5(config-if)#no sh
r5(config-if)#exit
r5(config)#
r5(config)#router rip
r5(config-router)#net 192.168.6.0 ?
<cr>

r5(config-router)#net 192.168.6.0
r5(config-router)#net 192.168.7.0
r5(config-router)#^Z
r5#ping 192.168.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
r5#show run
Building configuration...

Current configuration : 724 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname r5
!
!
ip subnet-zero
!
!
!
!
!
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 192.168.6.2 255.255.255.0
no fair-queue
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.7.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router rip
network 192.168.6.0
network 192.168.7.0
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end

r5#ping 192.168.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/16/40 ms
r5
r5#show ip rout
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.6.0/24 is directly connected, Serial1/0
C 192.168.7.0/24 is directly connected, Serial1/1
r5#ping 192.168.6.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/44 ms
r5#show ip rout
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
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.6.1 to network 0.0.0.0

R 192.168.4.0/24 [120/2] via 192.168.6.1, 00:00:20, Serial1/0
R 192.168.5.0/24 [120/2] via 192.168.6.1, 00:00:20, Serial1/0
C 192.168.6.0/24 is directly connected, Serial1/0
C 192.168.7.0/24 is directly connected, Serial1/1
R 192.168.1.0/24 [120/2] via 192.168.6.1, 00:00:20, Serial1/0
R 192.168.2.0/24 [120/2] via 192.168.6.1, 00:00:20, Serial1/0
R 192.168.3.0/24 [120/2] via 192.168.6.1, 00:00:20, Serial1/0
R* 0.0.0.0/0 [120/1] via 192.168.6.1, 00:00:20, Serial1/0
r5#

router6配置:

Router>en
Router#conf t
Router(config)#hostname r6
r6(config)#
r6(config)#line c 0
r6(config-line)#no exec-t
r6(config-line)#logging sy
r6(config-line)#exit
r6(config)#int s1/1
r6(config-if)#ip add 192.168.7.2 255.255.255.0
r6(config-if)#exit
r6(config)#router rip
r6(config-router)#net 192.168.7.0
r6(config-router)#exit
r6(config)#e^Z
r6#
r6#conf t
r6(config)#int s1/1
r6(config-if)#no s
r6(config-if)#^Z
r6#ping 192.168.7.1
00:41:04: %SYS-5-CONFIG_I: Configured from console by console
r6#ping 192.168.7.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/11/16 ms
r6#ping 192.168.6.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
r6#ping 192.168.6.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 16/37/52 ms
r6#ping 192.168.6.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/32/48 ms

r6#ping 192.168.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/84/128 ms
r6#
r6#
r6#

轉載於:https://blog.51cto.com/langzijishu/950636