Cisco Confidential 3BKACAD Tổng quan về hoạt động của OSPF Giao thức định tuyến “link state” có những đặc tính sau: Phản ứng nhanh với thay đổi của mạng Gửi gói tin cập nhật thông
Trang 1© 2008 Cisco Systems, Inc All rights reserved Cisco Confidential
OSPF
Quản trị mạng cơ bản
Trang 2Giao thức định tuyến nhóm Link-State
• Đầu tiên mỗi router xây dựng bức tranh tổng thể
về hệ thống mạng (bao gồm các thông tin liên kết (link) như băng thông, hàng xóm ID ) Sau
đó độc lập xác định tuyến đường hiệu quả nhất tới từng mạng
• Giao thức OSPF thuộc nhóm classless
• Hỗ trợ công nghệ VLSM và CIDR
Trang 3Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 3
BKACAD
Tổng quan về hoạt động của OSPF
Giao thức định tuyến “link state” có những đặc tính sau:
Phản ứng nhanh với thay đổi của mạng
Gửi gói tin cập nhật thông tin ngay khi có sự thay đổi
LSA là bản tin gửi đi theo kiểu tin cậy (ACK)
LSA có trường số thứ tự, giúp các router có thể
phân biệt
Trong quá trình hoạt động, router sẽ quảng bá bản
tin LSA theo địa chỉ multicast 224.0.0.5 hoặc 224.0.0.6
Trang 4Cấu trúc dữ liệu OSPF
Bảng Hàng Xóm (neighbor table)
Được biết tới như dữ liệu liền kề
Chứa đựng thông tin các hàng xóm đã được thiết lập
Bảng Topo (topology table):
Thường được gọi là Cơ sở dữ liệu trạng thái kết nối
(LSDB)
Chứa đựng thông tin về tất cả các router và link liên kết
với nó trong vùng (area) hoặc mạng (network)
Các router trong cùng 1 vùng sẽ có LSDB đồng nhất
Bảng định tuyến (routing table):
Đây là thông tin chuyển mạch (forwarding database)
Chứa đựng danh sách những tuyến đường tốt nhất
Trang 5Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 5
Đây là mô hình phân cấp
cần thiết, giảm thiểu
lượng LSP bị flood trong
mạng
Trang 6OSPF Router Types
Trang 7Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 7
BKACAD
Review of OSPF operation
Định dạng mào đầu gói tin OSPF (OSPF Packet Header
Format)
Các loại bản tin OSPF (OSPF Packet Types)
Thực hiện thiết lập mối quan hệ hàng xóm trong OSPF
(Establishing OSPF Neighbor Adjacencies)
Trao đổi và đồng bộ hóa cơ sở dữ liệu trạng thái liên kết
(Exchanging and Synchronizing LSDBs)
Khám phá các tuyến đường (Discovering the Network
Routes)
Bảo trì các tuyến đường (Maintaining Network Routes)
Bảo trì các bản tin LSA (Maintaining Link-State Sequence
Numbers)
Trang 8OSPF Packet Formats
Trang 9Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 9
BKACAD
OSPF Packet Types
Trang 10The Hello Packet
Trang 11Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 11
BKACAD
The Link State Request Packet
Trang 12The Link State Update Packet
Trang 13Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 13
BKACAD
The Link State Acknowledgment Packet
Trang 14OSPF – Thiết lập mối quan hệ hàng xóm
Trang 15Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 15
BKACAD
Link-State Database Synchronization (đồng bộ hóa cơ sở
dữ liệu)
Trang 16OSPF – Cấu hình cơ bản
Quản trị mạng cơ bản
Trang 17Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 17
BKACAD
Câu lệnh router ospf
Process-id (1 – 65,535): Được lựa chọn bởi quản trị viên
Chỉ có giá trị cục bộ (2 router chạy 2 process-id khác nhau vẫn có thể thết lật
mối quan hệ hàng xóm) → khác với giao thức EIGRP
Note: chúng ta thường lấy giá trị process-id trùng nhau để dễ quản lý
R1(config)# router ospf 1
R1(config-router)#
Trang 18Câu lệnh router ospf
Câu lệnh network được sử dụng tương tự với các giao thức
nội vùng khác
Tất cả các interface của router có địa chỉ IP nằm trong
dải mà câu lệnh network định nghĩa sẽ được kích hoạt để gửi và nhận bản tin OSPF
Bắt buộc phải sử dụng đi kèm với wildcard mask
Miền được quy định bởi area-id, các router muốn thiết
lập mối quan hệ với nhau cần có kết nối nằm trong cùng 1 Area
Router(config-router)# network network-address wildcard-mask area area-id
Trang 19Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 19
BKACAD
Câu lệnh router ospf
Wildcard mask có thể xây dựng bằng cách lấy ngược lại của giá trị subnet
mask.
Note: Giống như EIGRP, trong một số hệ điều hành IOS của cisco, router có
thể hiểu được câu lệnh với subnet mask (router tự động convert từ wildcard
mask sang subnet mask)
Trang 20Câu lệnh router ospf
area area-id: OSPF area ID
Các router trong cùng một Area sẽ chia sẻ và đồng bộ hóa với
nhau cơ sở dữ liệu
Trong bài này chúng ta sẽ chỉ sử dụng duy nhất một Area
0 mà thôi (single Area – đơn vùng).
Multi-area (đa vùng) sẽ được đề cập tới trong CCNP.
Router(config-router)# network network-address wildcard-mask area area-id
Trang 21Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 21
BKACAD
Câu lệnh network
Sử dụng câu lệnh network để kích hoạt giao thức OSPF trên các interface.
Sau khi thiết lập xong, mạng phải hội tụ, các router ping được lẫn nhau.
R1(config)# router ospf 1
R1(config-router)# network 172.16.1.16 0.0.0.15 area 0
R1(config-router)# network 192.168.10.0 0.0.0.3 area 0
R1(config-router)# network 192.168.10.4 0.0.0.3 area 0
R2(config)# router ospf 1
R2(config-router)# network 10.10.10.0 0.0.0.255 area 0
R2(config-router)# network 192.168.10.0 0.0.0.3 area 0
R2(config-router)# network 192.168.10.8 0.0.0.3 area 0
R3(config)# router ospf 1
R3(config-router)# network 172.16.1.32 0.0.0.7 area 0
R3(config-router)# network 192.168.10.4 0.0.0.3 area 0
R3(config-router)# network 192.168.10.8 0.0.0.3 area 0
Area-ID phải trùng nhau
Process-ID không nhất thiết phải giống nhau trên tất cả các router
Phải sử dụng wildcast mask
Trang 22 OSPF Router ID là một địa chỉ IP để phân biệt và xác định các router chạy
ospf khác nhau trong hệ thống mạng
What’s my Router ID?
What’s my Router ID?
Trang 23Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 23
BKACAD
Cisco router xây dựng router-id theo 3 bước sau
1 Cấu hình router-id trong mode (config-router)#
2 IP cao nhất của 1 loopback
3 IP cao nhất của 1 interface vật lý
Interface đó không nhất thiết phải kích hoạt giao thức ospf
What’s my Router ID?
What’s my Router ID?
Trang 24 Nếu không cấu hình router-id hay không có loopback, các
router lựa chọn router-id như thế nào ?
Trang 25Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 25
BKACAD
Kiểm tra Router ID
R1# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.10.5
<output omitted>
R2# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.10.9
<output omitted>
R3# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.10.10
<output omitted>
Trang 26Địa chỉ cổng Loopback
Ưu điểm của việc sử dụng địa chỉ loopback trước địa chỉ vật lý là do
loopback ổn định hơn, ko bị chết lỗi vật lý
Câu lệnh router-id được cisco router bổ sung gần đây Trước đó router-id
thường được biết đến là 1 IP của loopback
Router(config)# interface loopback number
Router(config-if)# ip address ip-address subnet-mask
R1(config)# interface loopback 0
Trang 27Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 27
BKACAD
1 Câu lệnh R(config-router)#router-id
2 IP cao nhất của loopback bất kỳ
3 Địa chỉ IP cao nhất của 1 interface vật lý đang bật.
Topology với địa
chỉ cổng
loopback
Trang 28Câu lệnh router-id
OSPF router-id command được đưa vào từ Cisco IOS Software 12.0(T)
và nó được ưu tiên hơn trong việc lựa chọn router-id so với địa chỉ của
loopback hay cổng vật lý
1 Câu lệnh R(config-router)#router-id
2 IP cao nhất của loopback bất kỳ
3 Địa chỉ IP cao nhất của 1 interface vật lý đang bật.
Router(config)# router ospf process-id
Router(config-router)# router-id ip-address
Trang 29Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 29
BKACAD
Thay đổi Router-ID (Extra)
Router-id được lựa chọn khi OSPF được cấu hình với câu lệnh OSPF
network đầu tiên
Nếu như câu lệnh router-id hay một interface loopback được cấu hình sau
câu lệnh OSPF network thì router-id được xác định là interface vật lý đang
hoạt động với ip cao nhất
Router-id có thể thay đổi về theo đúng thứ tự lựa chọn của nó bằng câu
lệnh:
Router# clear ip ospf process
chú ý: thay đổi router-id với cổng loopback hay vật lý có thể yêu cầu reload
lại router
Trang 30Trùng Router ID
Nếu router-id của 2 router hàng xóm giống nhau, thiết lập
mối quan hệ hàng xóm có thể không tiến hành, trên màn
hình có thể log ra thông điệp như trên
%OSPF-4-DUP_RTRID1: Detected router with duplicate router ID
Trang 31Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 31
BKACAD
Kiểm tra Router IDs (Loopbacks)
R1# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 10.1.1.1
<output omitted>
R2# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 10.2.2.2
<output omitted>
R3# show ip protocols
Routing Protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 10.3.3.3
<output omitted>
Trang 32Kiểm tra OSPF
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface10.3.3.3 1 FULL/ - 00:00:30 192.168.10.6 Serial0/0/110.2.2.2 1 FULL/ - 00:00:33 192.168.10.2 Serial0/0/0R2# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface10.3.3.3 1 FULL/ - 00:00:36 192.168.10.10 Serial0/0/110.1.1.1 1 FULL/ - 00:00:37 192.168.10.1 Serial0/0/0R3# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface10.2.2.2 1 FULL/ - 00:00:34 192.168.10.9 Serial0/0/110.1.1.1 1 FULL/ - 00:00:38 192.168.10.5 Serial0/0/0
Trang 33Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 33
BKACAD
Kiểm tra OSPF
Neighbor ID: Router-id của router hàng xóm.
Pri: OSPF priority - chỉ số port ưu tiên (later)
State: trạng thái router chạy OSPF
Trạng thái FULL có nghĩa là interface của router đã thiết lập mối quan hệ hàng
xóm, đồng bộ cơ sở dữ liệu thành công
Chi tiết về trạng thái của OSPF sẽ được đề cập tới trong CCNP
Dead Time: Tổng thời gian còn lại mà router sẽ đợi bản tin ospf hello trước khi loại
bỏ kết nối hàng xóm
Giá trị này sẽ reset về max khi nhận được bản tin hello
Address: địa chỉ IP của hàng xóm.
Interface: interface của router đang xét (R1)
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface10.3.3.3 1 FULL/ - 00:00:30 192.168.10.6 Serial0/0/110.2.2.2 1 FULL/ - 00:00:33 192.168.10.2 Serial0/0/0
Trang 34Kiểm tra OSPF
Đây là một câu lệnh rất hữu ích để khắc phục sự cố OSPF, các router cần thiết lập hàng xóm thành công trước khi trao đổi thông tin link-state
Note: trong mạng đa truy cập (multi-access) như Ethernet, 2 router có thể ở trạng thái 2WAY ( later)
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
Trang 35Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 35
BKACAD
2 router có thể không thiết lập được hàng xóm nếu:
Subnet masks không khớp
OSPF Hello hay Dead timers không khớp
OSPF network type không khớp
Cấu hình thiếu OSPF network.
Các câu lệnh nên sử dụng để khắc phục sự cố OSPF:
show ip protocols
show ip ospf
show ip ospf interface
Show ip ospf interface brief
R1# show ip ospf interface serial 0/0/0
Serial0/0/0 is up, line protocol is up
Transmit Delay is 1 sec, State POINT_TO_POINT,
<output omitted>
Kiểm tra OSPF
Trang 36Kiểm tra OSPF
R1# show ip protocols
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
10.3.3.3 110 11:29:29
OSPF Process ID OSPF Router ID
Networks OSPF is advertising that are originating from this router
OSPF Neighbors Administrative Distance
Trang 37Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 37
BKACAD
Kiểm tra OSPF
R1# show ip ospf
<some output omitted>
Start time: 00:00:19.540, Time elapsed: 11:31:15.776
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Incremental-SPF disabled
Minimum LSA interval 5 secs
Minimum LSA arrival 1000 msecs
Area BACKBONE(0)
Number of interfaces in this area is 3
Area has no authentication
SPF algorithm last executed 11:30:31.628 ago
SPF algorithm executed 5 times
Trang 38Kiểm tra OSPF
Mỗi khi router nhận được thông tin mới về topology (thêm, bớt, thay đổi link)
thì router sẽ:
Chạy lại thuật toán SPF
Tạo lại cây SPF
Cập nhật bảng định tuyến
… (in CCNP)
Việc chạy thuật toán SPF sẽ tiêu tốn tài nguyên của hệ thống mạng, và thời
gian tính toán phục thuộc vào kích thước mạng.
R1# show ip ospf
<some output omitted>
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Trang 39Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 39
BKACAD
Kiểm tra OSPF
Flapping link – Mạng có thể bị xoay vòng giữa up và down-> dẫn đến việc
OSPF router liên tục chạy thuật toán SPF
SPF schedule delay
Router sẽ chờ 5 giây (5000 msec) sau khi nhận được LSU mới chạy thuật
toán SPF
Minimum hold time:
Tránh trường hợp router liên tục chạy thuật toán SPF
Sau khi vừa chạy SPF, Router cần phải đợi 10 giây (10000 msec) trước
khi chạy lại SPF
R1# show ip ospf
<some output omitted>
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Trang 40Kiểm tra OSPF
OSPF có thể có các giá trị hello, dead interval khác nhau giữa các interface
trên 1 router
R1# show ip ospf interface serial 0/0/0
Serial0/0/0 is up, line protocol is up
Transmit Delay is 1 sec, State POINT_TO_POINT,
<output omitted>
Trang 41Presentation_ID © 2008 Cisco Systems, Inc All rights reserved Cisco Confidential 41
BKACAD
Kiểm tra bảng định tuyến
Không giống RIPv2 và EIGRP, OSPF mặc định không chạy chế độ auto-summary
R1# show ip route
Codes: <some code output omitted>
192.168.10.0/30 is subnetted, 3 subnets
C 192.168.10.0 is directly connected, Serial0/0/0
C 192.168.10.4 is directly connected, Serial0/0/1
O 192.168.10.8 [110/128] via 192.168.10.2, 14:27:57, Serial0/0/0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
O 172.16.1.32/29 [110/65] via 192.168.10.6, 14:27:57, Serial0/0/1
C 172.16.1.16/28 is directly connected, FastEthernet0/0
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 10.10.10.0/24 [110/65] via 192.168.10.2, 14:27:57, Serial0/0/0
C 10.1.1.1/32 is directly connected, Loopback0