ospf实例
在圖11-1,Mollie使用DLCI 201 與Neon 通信,使用DLCI 202 與Jelly通信, 使 用DLCI 203與Platty 通信。Neon 使用DLCI 101 與Mollie 通信,使用DLCI 102與Platty通信。Platty 使用DLCI 401與Neon 通信,使用DLCI 402與Mollie 通信。Jelly 使用DLCI 301與Mollie通信。
1. Mollie 的配置如下:
hostname mollie
!
interface serial 1
ip address 10.0.0.2 225.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay map ip 10.0.0.1 201 broadcast
frame-relay map ip 10.0.0.3 202 broadcast
frame-relay map ip 10.0.0.4 203 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.225 area 0
2. Neon 的配置如下:
hostname neon
!
interface serial 0
ip address 10.0.0.1 225.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay map ip 10.0.0.2 101 broadcast
frame-relay map ip 10.0.0.4 102 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
3. Platty的配置如下:
hostname platty
!
interface seria1 3
ip address 10.0.0.4 255.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
clock rate 1000000
frame-relay map ip 10.0.0.1 401 broadcast
frame-relay map ip 10.0.0.2 402 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
4. Jelly的配置如下:
hostname jelly
!
interface seria1 2
ip address 10.0.0.3 255.0.0.0
ip ospf network point-multipoint
encapsulation frame-relay
clock rate 2000000
frame-relay map ip 10.0.0.2 301 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
OSPF一對多接口廣播示例
下例為廣播形式的一對多接口網絡配置:
interface Serial 0
ip address 10.0.1.1 255.255.255.0
encapsulation frame-relay
ip ospf cost 100
ip ospf network point-to-multipoint
frame-relay map ip 10.0.1.3 202 broadcast
frame-relay map ip 10.0.1.4.203 broadcast
frame-relay map ip 10.0.1.5 204 broadcast
frame-relay local-dlci 200
!
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
neighbor 10.0.1.5 cost 5
neighbor 10.0.1.4 cost 10
下例顯示的是10.0.1.3上的鄰居配置:
interface serial 0
ip address 10.0.1.3 255.255.255.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay local-dlci 301
frame-relay map ip 10.0.1.1 300 broadcast
no shut
!
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
上面第一個配置中的鄰居的輸出顯示類似如下:
Router# show ip ospf neighbor
上面第一個配置中的路由信息類似如下:
Router# show ip route
Codes: 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, L1-IS-IS level-1, L2-IS-IS level-2, *-candidate defaultU-per-user static route, o-ODR
Gateway of last resort is not set
C 1.0.0.0/8 is directly connected, Loopback0
10.0.0.0/8 is variably subnetted,4 subnets, 2 masks
10.0.1.3/32 [110/100] via 10.0.1.3, 00:39:08, Serial0
C 10.0.1.0/24 is directly connected, Serial0
10.0.1.5/32 [110/5] via 10.0.1.5, 00:39:08, Serial0
10.0.1.4/32 [110/10] via 10.0.1.4, 00:39:08, Serial0OSPF一對多非廣播示例下例為非廣播形式的一對多網絡配置: interface Serial0 OSPF一對多非廣播示例下例
為非廣播形式的一對多網絡配置:
interface Serial0 ip address 10.0.1.1 255.255.255.0
ip ospf network point-to-multipointnon-broadcast
encapsulation frame-relay no keepalive
frame-relay local-dlci 200
frame-relay map ip 10.0.1.3 202
frame-relay map ip 10.0.1.4 203
frame-relay map ip 10.0.1.5 204
no shut !
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
neighbor 10.0.1.3 cost 5
neighbor 10.0.1.4 cost 10
neighbor 10.0.1.5.cost 15下例是另一端路由器上的配置:
interface Serial9/2
ip address 10.0.1.3 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-multipoint non-broadcast no ip mroute-cache
no keepalive
no fair-queue
frame-relay local-dlci 301
frame-relay map ip 10.0.1.1 300 no shut
!
router ospf 1
network 10.0.1.0
0.0.0.255 area 0 上面第一個配置中的鄰居的輸出顯示類似如下:
Router# show ip ospf neighbor
可變長度子網掩碼示例
OSPF、靜態路由和IS-IS支持可變長度子網掩碼(VLSM),因而可在不同接口上對同一網絡編號使用不同掩碼,保存IP地址,更有效地利用有效地址空間。
以下示例,使用30位子網掩碼,2位用來保留串行主機地址, 有足夠的主機地址空間提供給點對點串行鏈路上的主機兩端點。
interface ethernet0
ip address 131.107.1.1 255.255.255.0
!8 bits of host address space reserved for ethernets interface serial 0
ip address 131.107.254.1 255.255.255.252
! 2 bits of host address space reserved for serial lines ! Router is configured for OSPF and assigned AS 107
router ospf 107
! Specifies network directly connnected to the router
network 131.107.0.0 0.0.255.255 area 0.0.0.0OSPF路由選擇和路由重分配示例
OSPF的特色之一就是在許多內部路由器、區域邊界路由器和自治系統邊界路由器之 間取得協調。缺省參數值、無認證和分配區域的接口成為OSPF路由器的最低配置。 下表中的三個例子說明了特定情況的配置:
例一說明了基本OSPF命令的簡單設置 例二闡述了在單一性的強制指派OSPF自治系統內,
對內部路由器、區域邊界路由器(ABR)和自治系統邊界路由器(ASBR)所進行的設置。 例三是一個較復雜的設置,說明了運用不同工具來控制OSPF路由選擇環境。
1. 基本OSPF配置示例
下面的例子是一個簡單的OSPF設置,激活OSPF路由選擇進程9000,將以太網0連接到區域0.0.0.0,并重分配RIP到OSPF,重分配OSPF到RIP。
interface ethernet 0
ip address 130.93.1.1 255.255.255.0
ip ospf cost 1
! interface ethernet 1
ip address 13.94.1.1 255.255.255.0
! router ospf 9000
network 130.93.0.0 0.0.255.255 area 0.0.0.0
redistribute rip metric 1 subnets
! router rip
network 130.94.0.0
redistribute ospf 9000
default-metric 1
2. 對內部路由器、ABR和ASBR做基本OSPF配置的例子
下面的例子說明將四個區域ID分配給四個IP地址范圍。在這個例子中,初始化OSPF路由選擇進程109,定義四個OSPF區域:10.9.50.0,2,3和0。區域10.9.50.0,2和3屏蔽特定的地址范圍,而區域0為其他所有網絡激活OSPF。
router ospf 109
network 131.108.20.0 0.0.0.255 area 10.9.50.0
network 131.108.0.0 0.0.255.255 area 2
network 131.109.10.0 0.0.0.255 area 3
network 0.0.0.0 255.255.255.255 area 0
!
! Interface Ethernet0 is in area 10.9.50.0:
interface ethernet 0 !
! Interface Ethernet0 is in area 10.9.50.0:
interface ethernet 0
ip address 131.108.20.5 255.255.255.0
! ! Interface Ethernet 1 is in area 2:
interface ethernet 1
ip address 131.108.1.5 255.255.255.0
! !Interface Ethernet2 is in area 2:
interface ethernet2
ip address 131.108.2.5 255.255.255.0
! !Interface Ethernet3 is in area 3:
interface ethernet 3
ip address 131.109.10.5 255.255.255.0
! !Interface Ethernet4 is in area 0:
interface ethernet 4
ip address 131.109.1.1 255.255.255.0
! !Interface Ethernet5 is in area 0:
interface ethernet 5
ip address 10.1.0.1 255.255.0.0 繼續評估每個network路由器配置命令,因此配置中這些命令的順序是重要的。Cisco IOS軟件繼續為每個接口評估address/widcard-mask對,詳細信息請參看第十二章。
考慮第一個network area命令。區域ID 10.9.50.0設置給接口,子網131.108.20.0在此接口上定位。假定接口以太網0已匹配確認,接口以太網0連接到區域10.9.50.0。
接著評估第二個network area命令。對區域2,同樣的進程運用到所有接口(除接口以太網0外)。假定接口以太網1已匹配確認,然后對此接口激活OSPF,以太網1連接到區域2。
對所有network area命令,繼續將接口連接到OSPF區域過程。注意例子中最后一個network area命令是特殊情況。通過此命令,所有可用接口(未明確連接到其他區域)連接到區域0。
3. 復雜的內部路由器、ABR和ASBR例子
下面的例子簡述了在單一性OSPF自治系統內,配置幾個路由器。圖11-4提供了說明這個配置例子的總體網絡圖。
在OSPF自治系統109內設置5個路由器:
路由器A和路由器B都是區域1內的內部路由器。
路由器C是OSPF區域邊界路由器。注意對路由器C,區域1被分配給E3A,區域1被分配給E3,區域0被分配給S0。
路由器D是區域0 (主干區域)內的內部路由器。在這個例子里,兩個network路由器配置命令指定同一區域(區域0為主干區域)。 路由器E是OSPF自治系統邊界路由器。注意BGP路由被重分配到OSPF,OSPF通告這些路由。 注意:在配置自治系統中的全部路由器時,不必定義OSPF自治系統里的所有區域,只須 定義直接相連區域。在接下來的例子中,當區域邊界路由器(路由器C) 將匯總鏈路狀態 通告插入到區域1里時,區域1的路由器(路由器A和B)接收區域0中的路由。 自治系統109通過IP地址11.0.0.6到外部對等系統的BGP鏈路連接到外部。
圖11-4 樣本OSPF自治系統網絡圖
(1)路由器A—內部路由器
interface ethernet 1
ip address 131.108.1.1 255.255.255.0 router ospf 109
network 131.108.0.0 0.0.255.255 area 1 (2)路由器B—內部路由器
interfcae ethernet 2
ip address 131.108.1.2 255.255.255.0 router ospf 109
network 131.108.0.0 0.0.255.255 area 1 (3)路由器C—ABR
interface ethernet 3
ip address 131.108.1.3 255.255.255.0
nterface serial 0
ip address 131.108.2.3 255.255.255.0
router ospf 109
network 131.108.1.0 0.0.0.255 area 1
network 131.108.2.0 0.0.0.255 area 0
(4)路由器D—內部路由器
interface ethernet 4
ip address 10.0.0.4 255.0.0.0 interface serial 1
ip address 131.108.2.4 255.255.255.0 router ospf 109
network 131.108.2.0 0.0.0.255 area 0
network 10.0.0.0 0.255.255.255 area 0
(5)路由器E—ASBR
interface ethernet 5
ip address 10.0.0.5 255.0.0.0 interface serial 2
ip address 11.0.0.5 255.0.0.0 router ospf 109
network 10.0.0.0 0.255.255.255 area 0
redistribute bgp 109 metric 1 metric-type 1
router bgp 109
network 131.108.0.0
network 10.0.0.0
neighbor 11.0.0.6 remote-as 110 4. ABR復雜OSPF配置例子
下面的例子完成了對ABR的任務建立。這些任務分成下列兩大類:
基本OSPF配置 路由器分配
這個例子中的設置將在后面的說明中予以解釋。
圖11-5說明了網絡地址范圍以及對 接口的區域分配。
圖11-5 OSPF配置示例的接口和區域說明
例子中的基本配置任務如下:
為以太網0~3接口配置地址范圍
使每個接口的OSPF
為每個區域和網絡設立OSPF認證密鑰
分配鏈路狀態尺度和設置其他OSPF接口配置選項
創立區域ID為36.0.0.0的stub區域(注意:盡管area路由器配置命令的authentication 和stub選項可通過獨立的area命令項來指定,但仍可合并為一個area命令)。
指定主干區域(區域0)。
與重分配相關的配置任務如下
通過選項設置(包括metric-type,metric,tag和subnet),將IGRP和RIP重分配到OSPF。
將IGRP和OSPF重分配到RIP。
下面是OSPF配置的例子
interface ethernet 0
ip address 192.42.110.201 255.255.255.0
ip ospf authentication-key abcdefgh
ip ospf cost 10
! interface ethernet 1
ip address 131.119.251.201 225.255.255.0
ip ospf authentication-key ijklmnop ip ospf cost 20
ip ospf retransmit-interval 10
ip ospf transmit-delay 2
ip ospf priority 4
!
interface ethernet 2
ip address 131.119.254.201 255.255.255.0
ip ospf authentication-key abcdefgh
ip ospf cost 10
! interface ethernet 3
ip address 36.56.0.201 255.255.0.0
ip ospf authentication-key ijklmnop
ip ospf cost 20
ip ospf dead-interval 80 OSPF 在網絡131.119.0.0上:
router ospf 201
network 36.0.0.0 0.255.255.255 area 36.0.0.0
network 192.42.110.0 0.0.0.255 area 192.42.110.0
network 131.119.0.0 0.0.255.255 area 0 area 0 authentication
area 36.0.0.0 stub
area 36.0.0.0 authentication
area 36.0.0.0 default-cost 20
area 192.42.110.0 authentication
area 36.0.0.0 range 36.0.0.0 255.0.0.0
area 192.42.110.0 range 192.42.110.0 255.255.255.0
area 0 range 131.119.251.0 255.255.255.0
area 0 range 131.119.254.0 255.255.255.0
redistribute igrp 200 metric-type 2 metric 1 tag 200 subnets
redistribute rip metric-type 2 metric 1 tag 200
IGRP自治系統200在131.119.0.0上:
router igrp 200
network 131.119.0.0!
!RIP for 192.42.110!
router rip
network 192.42.110.0
redistribute igrp 200 metric 1
redistribute ospf 201 metric 1
路由映像示例
這部分的例子說明如何使用有或沒有路由映像的重分配,IP和CLNS路由選擇協議的例子都列在其中:
下面的例子
將所有OSPF重分配到IGRP:
router igrp 109
redistribute ospf 110
下面的例子將跳數為1的RIP路由器分配到OSPF,這些路由的尺度為5,尺度類型為1型,標識等于1,作為外部鏈路狀態廣告(LSA)重分配到OSPF:
router ospf 109
redistribute rip route-map rip-to-ospf
!
router-map rip-to-ospf permit
match metric 1
set metric 5
set metric-type type1
set tag 1 在下面的例子中,將OSPF以tag7獲取的路由作為RIP尺度15重分配: router rip
redistribute ospf 109 route-map 5 !
route-map 5 permit
match tag 7
set metric 15
在下面的例子中,將下一跳路由器在串行接口0上的OSPF區域內和區域間路由重分配到INTER_AS尺度為5的BGP: router bgp 109
redistribute ospf 109
route-map 10
! route-map 10 permit
match route-type internal
match interface serial 0
et metric 5 下面的例子將兩類路由重分配到綜合IS-IS路由選擇表(支持IP和CLNS),第一類路 由是tag 5的OSPF外部IP路由,這些路由以尺度5插入2級IS-IS LSP;第二類是ISO-IGRP,來自CLNS報頭路由并與CLNS訪問表2000匹配,它們將作為2級LSP以尺度30重分配到 IS-IS。 router isis redistribute ospf 109 route-map 2 redistribute iso-igrp nsfnet route-map 3!route-map 2 permit match route-type external match tag 5 set metric set level level-2 router isis
redistribute ospf 109 route-map 2
redistribute iso-igrp nsfnet route-map 3
!
route-map 2 permit
match route-type external
match tag 5 set metric
set level level-2 !
route-map 3 permit
match address 2000
set metric 30
tage 1,2,3和5的OSPF外部路由分別以尺度1,1,5和5重分配到RIP,tag為4的OSPF路由不重分配:
router rip
redistribute ospf 109 route-map 1
! route-map 1 permit
match tag 1 2
set metric 1
! route-map 1 permit
match tag 3
set metric 5
! route-map 1 deny
match tag 4
! route map 1
permit match tag 5
set metric 5 如果有到網絡140.222.0.0的OSPF路由,就產生尺度為1的缺省網絡0.0.0.0到RIP,配置如下:
router rip
redistribute ospf 109 route-map default
! route-map default permit
match ip address 1
set metric 1
! access-list 1 permit 140.222.0.0 0.0.255.255
access-list 2 permit 0.0.0.0 0.0.0.0 在下面的配置中,為網絡160.89.0.0獲取路由的RIP以及以報頭49.0001.0002獲取路由的ISO-IGRP,將以尺度5重分配為IS-IS 2級LSP:
router isis
redistribute rip route-map 1
redistribute iso-igrp remote route-map 1
! route map 1 permit
match ip address 1
match clns address 2
set metric 5
set level level-2 !
access-list 1 permit 160.89.0.0 0.0.255.255
clns filter-set 2 permit 49.0001.0002… 下面的便子說明路映像如何被default-configuration路由器配置命令引用,這被稱為條件缺省源(conditional defualt origination).OSPF將產生缺省路由(網絡 0.0.0.0),基于140.222.0.0上2型尺度為5網絡0.0.0.0 在路由選擇表中。
route-map ospf-default permit
match ip address 1
set metric 5
set metri-type type-2
!
access-list 1 140.222.0.0 0.0.255.255
!
router ospf 109
default-information originate router-map ospf-default 修改OSPF 管轄距離示例
下例將外部距離修改為200,使其幾乎不可信。如圖11-6所示。路由器A
router ospf 1
redistribue ospf2 subnet
distance ospf external 200
!
router ospf 2
redistribute ospf subnet
distance ospf external 200
路由器B
router ospf 1
redistribute ospf 2 subnet
distance ospf external 200
! router ospf 2
redistribute ospf 1 subnet
distance ospf external 200 按需路由選擇上的OSPF示例
下面是按需要電路OSPF的配置,如圖11-7所示。注意,按需要電路只定義在一邊(路由器A上的BR10)。不需要要兩邊都配置。
圖11-7 按需電路上的OSPF
路由器A
username RouterB password 7 060C1A2F47
isdn switch-type basic-5ess
ip routing !
interface TokenRing0
ip address 140.10.20.7 255.255.255.0
no shut
! interface BRI0
no cdp enable description connected PBX 1485
ip address 140.10.10.7 255.255.255.0
encapsulation ppp
ip ospf demand-circuit
dialer map ip 140.10.10.6 name RouterB broadcast 61484
dialer-group 1
ppp authentication chap
no shut
!
router ospf 100
network 140.10.10.0 0.0.0.255 area 0
network 140.10.20.0 0.0.0.255 area 0
!
dialer-list 1 protocol ip permit
路由器B
username RouterA password 7 04511E0804
isdn switch-type basic-5ess
ip routing
!
interface Ethernet0
ip address 140.10.60.6 255.255.255.0 no shut
!
interface BRI0
no cdp enable
description connected PBX 1484
ip address 140.10.10.6 255.255.255.0
encapsulation ppp
dialer map ip 140.10.10.7 name RouterA broadcast 61485
dialer-group 1
ppp authentication chap
no shut
!
router ospf 100
network 140.10.10.0 0.0.0.255 area 0
network 140.10.60.0 0.0.0.255 area 0
!
dialer-list 1 protocol ip permitL
SA組定步示例 下面將OSPF LSA 組定步修改為60秒:
router ospf timers lsa-group-pacing 60
阻止LSA擴散示例 下例配置阻止OSPF LSA通過以太網口擴散到廣播、非廣播或點對點的可達網絡。 interface ethernet 0
ospf database-filter all out
下例配置阻止OSPF LSA通過IP地址為1.2.3.4的鄰居擴散到一對多的網絡。
router ospf 109
neighbor 1.2.3.4 database-filter all out 忽略MOSPF LSA 包示例
下例配置路由器使其在接收MOSPF 信息包時抑制發送系統注冊信息。
router ospf 109
ospf ignore lsa mospf 實例 職場 ospf
1. Mollie 的配置如下:
hostname mollie
!
interface serial 1
ip address 10.0.0.2 225.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay map ip 10.0.0.1 201 broadcast
frame-relay map ip 10.0.0.3 202 broadcast
frame-relay map ip 10.0.0.4 203 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.225 area 0
2. Neon 的配置如下:
hostname neon
!
interface serial 0
ip address 10.0.0.1 225.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay map ip 10.0.0.2 101 broadcast
frame-relay map ip 10.0.0.4 102 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
3. Platty的配置如下:
hostname platty
!
interface seria1 3
ip address 10.0.0.4 255.0.0.0
ip ospf network point-to-multipoint
encapsulation frame-relay
clock rate 1000000
frame-relay map ip 10.0.0.1 401 broadcast
frame-relay map ip 10.0.0.2 402 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
4. Jelly的配置如下:
hostname jelly
!
interface seria1 2
ip address 10.0.0.3 255.0.0.0
ip ospf network point-multipoint
encapsulation frame-relay
clock rate 2000000
frame-relay map ip 10.0.0.2 301 broadcast
!
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
OSPF一對多接口廣播示例
下例為廣播形式的一對多接口網絡配置:
interface Serial 0
ip address 10.0.1.1 255.255.255.0
encapsulation frame-relay
ip ospf cost 100
ip ospf network point-to-multipoint
frame-relay map ip 10.0.1.3 202 broadcast
frame-relay map ip 10.0.1.4.203 broadcast
frame-relay map ip 10.0.1.5 204 broadcast
frame-relay local-dlci 200
!
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
neighbor 10.0.1.5 cost 5
neighbor 10.0.1.4 cost 10
下例顯示的是10.0.1.3上的鄰居配置:
interface serial 0
ip address 10.0.1.3 255.255.255.0
ip ospf network point-to-multipoint
encapsulation frame-relay
frame-relay local-dlci 301
frame-relay map ip 10.0.1.1 300 broadcast
no shut
!
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
上面第一個配置中的鄰居的輸出顯示類似如下:
Router# show ip ospf neighbor
| Neighbor ID | Pri State | Dead Time | Address | Interface |
| 4.1.1.1 | 1 FULL/ - | 00:01:50 | 10.0.1.5 | Serial0 |
| 3.1.1.1 | 1 FULL/ - | 00:01:47 | 10.0.1.4 | Serial0 |
| 2.1.1.1 | 1 FULL/ - | 00:01:45 | 10.0.1.3 | Serial0 |
Router# show ip route
Codes: 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, L1-IS-IS level-1, L2-IS-IS level-2, *-candidate defaultU-per-user static route, o-ODR
Gateway of last resort is not set
C 1.0.0.0/8 is directly connected, Loopback0
10.0.0.0/8 is variably subnetted,4 subnets, 2 masks
10.0.1.3/32 [110/100] via 10.0.1.3, 00:39:08, Serial0
C 10.0.1.0/24 is directly connected, Serial0
10.0.1.5/32 [110/5] via 10.0.1.5, 00:39:08, Serial0
10.0.1.4/32 [110/10] via 10.0.1.4, 00:39:08, Serial0OSPF一對多非廣播示例下例為非廣播形式的一對多網絡配置: interface Serial0 OSPF一對多非廣播示例下例
為非廣播形式的一對多網絡配置:
interface Serial0 ip address 10.0.1.1 255.255.255.0
ip ospf network point-to-multipointnon-broadcast
encapsulation frame-relay no keepalive
frame-relay local-dlci 200
frame-relay map ip 10.0.1.3 202
frame-relay map ip 10.0.1.4 203
frame-relay map ip 10.0.1.5 204
no shut !
router ospf 1
network 10.0.1.0 0.0.0.255 area 0
neighbor 10.0.1.3 cost 5
neighbor 10.0.1.4 cost 10
neighbor 10.0.1.5.cost 15下例是另一端路由器上的配置:
interface Serial9/2
ip address 10.0.1.3 255.255.255.0
encapsulation frame-relay
ip ospf network point-to-multipoint non-broadcast no ip mroute-cache
no keepalive
no fair-queue
frame-relay local-dlci 301
frame-relay map ip 10.0.1.1 300 no shut
!
router ospf 1
network 10.0.1.0
0.0.0.255 area 0 上面第一個配置中的鄰居的輸出顯示類似如下:
Router# show ip ospf neighbor
| Neighbor ID | Pri State | Dead Time | Address | Interface |
| 4.1.1.1 | 1 FULL/ - | 00:01:52 | 10.0.1.5 | Serial0 |
| 3.1.1.1 | 1 FULL/ - | 00:01:52 | 10.0.1.4 | Serial0 |
| 2.1.1.1 | 1 FULL/ - | 00:01:52 | 10.0.1.3 | Serial0 |
OSPF、靜態路由和IS-IS支持可變長度子網掩碼(VLSM),因而可在不同接口上對同一網絡編號使用不同掩碼,保存IP地址,更有效地利用有效地址空間。
以下示例,使用30位子網掩碼,2位用來保留串行主機地址, 有足夠的主機地址空間提供給點對點串行鏈路上的主機兩端點。
interface ethernet0
ip address 131.107.1.1 255.255.255.0
!8 bits of host address space reserved for ethernets interface serial 0
ip address 131.107.254.1 255.255.255.252
! 2 bits of host address space reserved for serial lines ! Router is configured for OSPF and assigned AS 107
router ospf 107
! Specifies network directly connnected to the router
network 131.107.0.0 0.0.255.255 area 0.0.0.0OSPF路由選擇和路由重分配示例
OSPF的特色之一就是在許多內部路由器、區域邊界路由器和自治系統邊界路由器之 間取得協調。缺省參數值、無認證和分配區域的接口成為OSPF路由器的最低配置。 下表中的三個例子說明了特定情況的配置:
例一說明了基本OSPF命令的簡單設置 例二闡述了在單一性的強制指派OSPF自治系統內,
對內部路由器、區域邊界路由器(ABR)和自治系統邊界路由器(ASBR)所進行的設置。 例三是一個較復雜的設置,說明了運用不同工具來控制OSPF路由選擇環境。
1. 基本OSPF配置示例
下面的例子是一個簡單的OSPF設置,激活OSPF路由選擇進程9000,將以太網0連接到區域0.0.0.0,并重分配RIP到OSPF,重分配OSPF到RIP。
interface ethernet 0
ip address 130.93.1.1 255.255.255.0
ip ospf cost 1
! interface ethernet 1
ip address 13.94.1.1 255.255.255.0
! router ospf 9000
network 130.93.0.0 0.0.255.255 area 0.0.0.0
redistribute rip metric 1 subnets
! router rip
network 130.94.0.0
redistribute ospf 9000
default-metric 1
2. 對內部路由器、ABR和ASBR做基本OSPF配置的例子
下面的例子說明將四個區域ID分配給四個IP地址范圍。在這個例子中,初始化OSPF路由選擇進程109,定義四個OSPF區域:10.9.50.0,2,3和0。區域10.9.50.0,2和3屏蔽特定的地址范圍,而區域0為其他所有網絡激活OSPF。
router ospf 109
network 131.108.20.0 0.0.0.255 area 10.9.50.0
network 131.108.0.0 0.0.255.255 area 2
network 131.109.10.0 0.0.0.255 area 3
network 0.0.0.0 255.255.255.255 area 0
!
! Interface Ethernet0 is in area 10.9.50.0:
interface ethernet 0 !
! Interface Ethernet0 is in area 10.9.50.0:
interface ethernet 0
ip address 131.108.20.5 255.255.255.0
! ! Interface Ethernet 1 is in area 2:
interface ethernet 1
ip address 131.108.1.5 255.255.255.0
! !Interface Ethernet2 is in area 2:
interface ethernet2
ip address 131.108.2.5 255.255.255.0
! !Interface Ethernet3 is in area 3:
interface ethernet 3
ip address 131.109.10.5 255.255.255.0
! !Interface Ethernet4 is in area 0:
interface ethernet 4
ip address 131.109.1.1 255.255.255.0
! !Interface Ethernet5 is in area 0:
interface ethernet 5
ip address 10.1.0.1 255.255.0.0 繼續評估每個network路由器配置命令,因此配置中這些命令的順序是重要的。Cisco IOS軟件繼續為每個接口評估address/widcard-mask對,詳細信息請參看第十二章。
考慮第一個network area命令。區域ID 10.9.50.0設置給接口,子網131.108.20.0在此接口上定位。假定接口以太網0已匹配確認,接口以太網0連接到區域10.9.50.0。
接著評估第二個network area命令。對區域2,同樣的進程運用到所有接口(除接口以太網0外)。假定接口以太網1已匹配確認,然后對此接口激活OSPF,以太網1連接到區域2。
對所有network area命令,繼續將接口連接到OSPF區域過程。注意例子中最后一個network area命令是特殊情況。通過此命令,所有可用接口(未明確連接到其他區域)連接到區域0。
3. 復雜的內部路由器、ABR和ASBR例子
下面的例子簡述了在單一性OSPF自治系統內,配置幾個路由器。圖11-4提供了說明這個配置例子的總體網絡圖。
在OSPF自治系統109內設置5個路由器:
路由器A和路由器B都是區域1內的內部路由器。
路由器C是OSPF區域邊界路由器。注意對路由器C,區域1被分配給E3A,區域1被分配給E3,區域0被分配給S0。
路由器D是區域0 (主干區域)內的內部路由器。在這個例子里,兩個network路由器配置命令指定同一區域(區域0為主干區域)。 路由器E是OSPF自治系統邊界路由器。注意BGP路由被重分配到OSPF,OSPF通告這些路由。 注意:在配置自治系統中的全部路由器時,不必定義OSPF自治系統里的所有區域,只須 定義直接相連區域。在接下來的例子中,當區域邊界路由器(路由器C) 將匯總鏈路狀態 通告插入到區域1里時,區域1的路由器(路由器A和B)接收區域0中的路由。 自治系統109通過IP地址11.0.0.6到外部對等系統的BGP鏈路連接到外部。
圖11-4 樣本OSPF自治系統網絡圖
(1)路由器A—內部路由器
interface ethernet 1
ip address 131.108.1.1 255.255.255.0 router ospf 109
network 131.108.0.0 0.0.255.255 area 1 (2)路由器B—內部路由器
interfcae ethernet 2
ip address 131.108.1.2 255.255.255.0 router ospf 109
network 131.108.0.0 0.0.255.255 area 1 (3)路由器C—ABR
interface ethernet 3
ip address 131.108.1.3 255.255.255.0
nterface serial 0
ip address 131.108.2.3 255.255.255.0
router ospf 109
network 131.108.1.0 0.0.0.255 area 1
network 131.108.2.0 0.0.0.255 area 0
(4)路由器D—內部路由器
interface ethernet 4
ip address 10.0.0.4 255.0.0.0 interface serial 1
ip address 131.108.2.4 255.255.255.0 router ospf 109
network 131.108.2.0 0.0.0.255 area 0
network 10.0.0.0 0.255.255.255 area 0
(5)路由器E—ASBR
interface ethernet 5
ip address 10.0.0.5 255.0.0.0 interface serial 2
ip address 11.0.0.5 255.0.0.0 router ospf 109
network 10.0.0.0 0.255.255.255 area 0
redistribute bgp 109 metric 1 metric-type 1
router bgp 109
network 131.108.0.0
network 10.0.0.0
neighbor 11.0.0.6 remote-as 110 4. ABR復雜OSPF配置例子
下面的例子完成了對ABR的任務建立。這些任務分成下列兩大類:
基本OSPF配置 路由器分配
這個例子中的設置將在后面的說明中予以解釋。
圖11-5說明了網絡地址范圍以及對 接口的區域分配。
圖11-5 OSPF配置示例的接口和區域說明
例子中的基本配置任務如下:
為以太網0~3接口配置地址范圍
使每個接口的OSPF
為每個區域和網絡設立OSPF認證密鑰
分配鏈路狀態尺度和設置其他OSPF接口配置選項
創立區域ID為36.0.0.0的stub區域(注意:盡管area路由器配置命令的authentication 和stub選項可通過獨立的area命令項來指定,但仍可合并為一個area命令)。
指定主干區域(區域0)。
與重分配相關的配置任務如下
通過選項設置(包括metric-type,metric,tag和subnet),將IGRP和RIP重分配到OSPF。
將IGRP和OSPF重分配到RIP。
下面是OSPF配置的例子
interface ethernet 0
ip address 192.42.110.201 255.255.255.0
ip ospf authentication-key abcdefgh
ip ospf cost 10
! interface ethernet 1
ip address 131.119.251.201 225.255.255.0
ip ospf authentication-key ijklmnop ip ospf cost 20
ip ospf retransmit-interval 10
ip ospf transmit-delay 2
ip ospf priority 4
!
interface ethernet 2
ip address 131.119.254.201 255.255.255.0
ip ospf authentication-key abcdefgh
ip ospf cost 10
! interface ethernet 3
ip address 36.56.0.201 255.255.0.0
ip ospf authentication-key ijklmnop
ip ospf cost 20
ip ospf dead-interval 80 OSPF 在網絡131.119.0.0上:
router ospf 201
network 36.0.0.0 0.255.255.255 area 36.0.0.0
network 192.42.110.0 0.0.0.255 area 192.42.110.0
network 131.119.0.0 0.0.255.255 area 0 area 0 authentication
area 36.0.0.0 stub
area 36.0.0.0 authentication
area 36.0.0.0 default-cost 20
area 192.42.110.0 authentication
area 36.0.0.0 range 36.0.0.0 255.0.0.0
area 192.42.110.0 range 192.42.110.0 255.255.255.0
area 0 range 131.119.251.0 255.255.255.0
area 0 range 131.119.254.0 255.255.255.0
redistribute igrp 200 metric-type 2 metric 1 tag 200 subnets
redistribute rip metric-type 2 metric 1 tag 200
IGRP自治系統200在131.119.0.0上:
router igrp 200
network 131.119.0.0!
!RIP for 192.42.110!
router rip
network 192.42.110.0
redistribute igrp 200 metric 1
redistribute ospf 201 metric 1
路由映像示例
這部分的例子說明如何使用有或沒有路由映像的重分配,IP和CLNS路由選擇協議的例子都列在其中:
下面的例子
將所有OSPF重分配到IGRP:
router igrp 109
redistribute ospf 110
下面的例子將跳數為1的RIP路由器分配到OSPF,這些路由的尺度為5,尺度類型為1型,標識等于1,作為外部鏈路狀態廣告(LSA)重分配到OSPF:
router ospf 109
redistribute rip route-map rip-to-ospf
!
router-map rip-to-ospf permit
match metric 1
set metric 5
set metric-type type1
set tag 1 在下面的例子中,將OSPF以tag7獲取的路由作為RIP尺度15重分配: router rip
redistribute ospf 109 route-map 5 !
route-map 5 permit
match tag 7
set metric 15
在下面的例子中,將下一跳路由器在串行接口0上的OSPF區域內和區域間路由重分配到INTER_AS尺度為5的BGP: router bgp 109
redistribute ospf 109
route-map 10
! route-map 10 permit
match route-type internal
match interface serial 0
et metric 5 下面的例子將兩類路由重分配到綜合IS-IS路由選擇表(支持IP和CLNS),第一類路 由是tag 5的OSPF外部IP路由,這些路由以尺度5插入2級IS-IS LSP;第二類是ISO-IGRP,來自CLNS報頭路由并與CLNS訪問表2000匹配,它們將作為2級LSP以尺度30重分配到 IS-IS。 router isis redistribute ospf 109 route-map 2 redistribute iso-igrp nsfnet route-map 3!route-map 2 permit match route-type external match tag 5 set metric set level level-2 router isis
redistribute ospf 109 route-map 2
redistribute iso-igrp nsfnet route-map 3
!
route-map 2 permit
match route-type external
match tag 5 set metric
set level level-2 !
route-map 3 permit
match address 2000
set metric 30
tage 1,2,3和5的OSPF外部路由分別以尺度1,1,5和5重分配到RIP,tag為4的OSPF路由不重分配:
router rip
redistribute ospf 109 route-map 1
! route-map 1 permit
match tag 1 2
set metric 1
! route-map 1 permit
match tag 3
set metric 5
! route-map 1 deny
match tag 4
! route map 1
permit match tag 5
set metric 5 如果有到網絡140.222.0.0的OSPF路由,就產生尺度為1的缺省網絡0.0.0.0到RIP,配置如下:
router rip
redistribute ospf 109 route-map default
! route-map default permit
match ip address 1
set metric 1
! access-list 1 permit 140.222.0.0 0.0.255.255
access-list 2 permit 0.0.0.0 0.0.0.0 在下面的配置中,為網絡160.89.0.0獲取路由的RIP以及以報頭49.0001.0002獲取路由的ISO-IGRP,將以尺度5重分配為IS-IS 2級LSP:
router isis
redistribute rip route-map 1
redistribute iso-igrp remote route-map 1
! route map 1 permit
match ip address 1
match clns address 2
set metric 5
set level level-2 !
access-list 1 permit 160.89.0.0 0.0.255.255
clns filter-set 2 permit 49.0001.0002… 下面的便子說明路映像如何被default-configuration路由器配置命令引用,這被稱為條件缺省源(conditional defualt origination).OSPF將產生缺省路由(網絡 0.0.0.0),基于140.222.0.0上2型尺度為5網絡0.0.0.0 在路由選擇表中。
route-map ospf-default permit
match ip address 1
set metric 5
set metri-type type-2
!
access-list 1 140.222.0.0 0.0.255.255
!
router ospf 109
default-information originate router-map ospf-default 修改OSPF 管轄距離示例
下例將外部距離修改為200,使其幾乎不可信。如圖11-6所示。路由器A
router ospf 1
redistribue ospf2 subnet
distance ospf external 200
!
router ospf 2
redistribute ospf subnet
distance ospf external 200
路由器B
router ospf 1
redistribute ospf 2 subnet
distance ospf external 200
! router ospf 2
redistribute ospf 1 subnet
distance ospf external 200 按需路由選擇上的OSPF示例
下面是按需要電路OSPF的配置,如圖11-7所示。注意,按需要電路只定義在一邊(路由器A上的BR10)。不需要要兩邊都配置。
圖11-7 按需電路上的OSPF
路由器A
username RouterB password 7 060C1A2F47
isdn switch-type basic-5ess
ip routing !
interface TokenRing0
ip address 140.10.20.7 255.255.255.0
no shut
! interface BRI0
no cdp enable description connected PBX 1485
ip address 140.10.10.7 255.255.255.0
encapsulation ppp
ip ospf demand-circuit
dialer map ip 140.10.10.6 name RouterB broadcast 61484
dialer-group 1
ppp authentication chap
no shut
!
router ospf 100
network 140.10.10.0 0.0.0.255 area 0
network 140.10.20.0 0.0.0.255 area 0
!
dialer-list 1 protocol ip permit
路由器B
username RouterA password 7 04511E0804
isdn switch-type basic-5ess
ip routing
!
interface Ethernet0
ip address 140.10.60.6 255.255.255.0 no shut
!
interface BRI0
no cdp enable
description connected PBX 1484
ip address 140.10.10.6 255.255.255.0
encapsulation ppp
dialer map ip 140.10.10.7 name RouterA broadcast 61485
dialer-group 1
ppp authentication chap
no shut
!
router ospf 100
network 140.10.10.0 0.0.0.255 area 0
network 140.10.60.0 0.0.0.255 area 0
!
dialer-list 1 protocol ip permitL
SA組定步示例 下面將OSPF LSA 組定步修改為60秒:
router ospf timers lsa-group-pacing 60
阻止LSA擴散示例 下例配置阻止OSPF LSA通過以太網口擴散到廣播、非廣播或點對點的可達網絡。 interface ethernet 0
ospf database-filter all out
下例配置阻止OSPF LSA通過IP地址為1.2.3.4的鄰居擴散到一對多的網絡。
router ospf 109
neighbor 1.2.3.4 database-filter all out 忽略MOSPF LSA 包示例
下例配置路由器使其在接收MOSPF 信息包時抑制發送系統注冊信息。
router ospf 109
ospf ignore lsa mospf 實例 職場 ospf
0
微博 QQ 微信收藏
上一篇:ospf詳解 下一篇:QoS s3132645056篇文章,6596人氣,0粉絲
Ctrl+Enter?發布
發布
取消
推薦專欄更多
網絡安全入門到實戰,讓SQLmap子彈飛一會兒9本網絡安全實戰書籍精華
共23章?|?simeon2005
¥51.00 828人訂閱
訂???閱 Web網站安全評估分析及防御企業級網安運維
共30章?|?simeon2005
¥51.00 407人訂閱
訂???閱 負載均衡高手煉成記高并發架構之路
共15章?|?sery
¥51.00 506人訂閱
訂???閱猜你喜歡
我的友情鏈接 ospf實例 CCNP OSPF協議詳解 OSPF基本配置 Java線程:線程的調度-休眠 我們不得不面對的中年職場危機 OSPF(ABR和ASBR)的路由匯總 OSPF詳解之三:OSPF LSA詳解 職場終極密籍--記我的職業生涯 用光影魔術手制作一寸照片(8張一寸) OSPF的七種狀態機 H3C設備之OSPF的配置 OSPF基本概念以及DR/BDR和虛連接OSPF特殊區域的實驗操作 簡單搭建OSPF,RIP,NSSA,外部路由匯總網絡拓撲 OSPF路由重分發 OSPF協議的“地址匯總配置”及“虛鏈路配置” 華為路由器BGP鄰居詳解 H3C 交換機升級說明 網工,敢問路在何方?! 小試牛刀(一):家用級組網規劃設計與配置實戰掃一掃,領取大禮包
0
分享 s313264505轉載于:https://blog.51cto.com/313264505/283377
總結
- 上一篇: AIX忘记root密码后,重设密码步骤
- 下一篇: (转)CXF学习笔记一:如何创建、发布和