چیتشیت کامل OSPF برای سیسکو
راهنمای کامل OSPF (Open Shortest Path First) روی سیسکو؛ از مفاهیم پایه تا Multi-Area، Authentication، انواع خاص Area، Virtual Link، Redistribution و Troubleshooting.
مقدمه
OSPF یک پروتکل مسیریابی Link-State استاندارد (IETF) است که در شبکههای بزرگ سازمانی و Service Provider استفاده میشود. برخلاف پروتکلهای Distance-Vector مثل RIP، OSPF توپولوژی کامل شبکه را در Link-State Database (LSDB) نگه میدارد و با الگوریتم Dijkstra (SPF) بهترین مسیر را محاسبه میکند.
۱. مفاهیم پایهٔ OSPF
ویژگیهای کلیدی:
- Classless (پشتیبانی کامل از VLSM و CIDR)
- پشتیبانی از Multi-Area برای مقیاسپذیری
- همگرایی سریع
- استفاده از Metric به نام Cost
- پشتیبانی از Authentication
- Administrative Distance پیشفرض: ۱۱۰
انواع روتر در OSPF
| نوع روتر | توضیح |
|---|---|
| Internal Router | همهٔ اینترفیسها در یک Area |
| ABR (Area Border Router) | اتصال به چند Area (حداقل یکی Area 0) |
| ASBR (Autonomous System Boundary Router) | اتصال به پروتکلهای دیگر یا Static Route (Redistribution) |
| Backbone Router | حداقل یک اینترفیس در Area 0 |
انواع Area
| نوع Area | توضیح |
|---|---|
| Area 0 (Backbone) | اجباری؛ همهٔ Areaهای دیگر باید به آن وصل باشند |
| Standard/Normal Area | همهٔ انواع LSA مجاز |
| Stub Area | Type 5 (External) ممنوع + Default Route از ABR |
| Totally Stubby Area (Cisco proprietary) | Type 3 و Type 5 ممنوع + فقط Default Route |
| NSSA (Not-So-Stubby Area) | اجازهٔ Redistribution داخلی با Type 7 |
| Totally NSSA | ترکیب Totally Stubby + NSSA |
انواع LSA اصلی
| Type | نام | تولیدکننده | محدودهٔ Flooding | توضیح |
|---|---|---|---|---|
| 1 | Router LSA | همهٔ روترها | داخل Area | لینکهای روتر |
| 2 | Network LSA | DR | داخل Area | شبکهٔ Multi-Access |
| 3 | Summary LSA | ABR | بین Areaها | مسیرهای Inter-Area |
| 4 | ASBR Summary LSA | ABR | بین Areaها | مسیر به ASBR |
| 5 | External LSA | ASBR | کل دامنهٔ OSPF (بهجز Stub) | مسیرهای خارجی |
| 7 | NSSA External LSA | ASBR در NSSA | فقط داخل NSSA | مسیر خارجی در NSSA (بعداً به Type 5 تبدیل میشود) |
حالات Neighbor (Neighbor States)
Down → Init → 2-Way → ExStart → Exchange → Loading → Full
محاسبهٔ Cost
Cost = Reference Bandwidth / Interface Bandwidth
پیشفرض Reference Bandwidth = ۱۰۰ Mbps
دستور تغییر (در حالت Router Configuration):
auto-cost reference-bandwidth <Mbps>
۲. پیکربندی پایهٔ OSPF (Single Area)
روش قدیمی (Network Statement)
router ospf 1
router-id 1.1.1.1
network 10.0.0.0 0.255.255.255 area 0
network 192.168.1.0 0.0.0.255 area 0
passive-interface default
no passive-interface GigabitEthernet0/0
روش توصیهشدهٔ مدرن (Interface-based)
interface GigabitEthernet0/0
ip ospf 1 area 0
!
interface Loopback0
ip ospf 1 area 0
!
router ospf 1
router-id 1.1.1.1
دستورات مهم Interface
ip ospf cost <value>
ip ospf priority <0-255> # برای DR/BDR (0 = هرگز DR نمیشود)
ip ospf hello-interval <seconds>
ip ospf dead-interval <seconds>
ip ospf network {broadcast | non-broadcast | point-to-point | point-to-multipoint}
ip ospf mtu-ignore
۳. Multi-Area OSPF
روی ABR:
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
network 172.16.0.0 0.0.255.255 area 10
network 192.168.0.0 0.0.255.255 area 20
۴. Authentication
Clear-text
router ospf 1
area 0 authentication
!
interface GigabitEthernet0/0
ip ospf authentication-key MyPass
MD5 (توصیهشده)
router ospf 1
area 0 authentication message-digest
!
interface GigabitEthernet0/0
ip ospf message-digest-key 1 md5 MySecretKey
Key-chain (مدرنتر)
key chain OSPF-KEY
key 1
key-string MySecretKey
cryptographic-algorithm hmac-sha-256
!
interface GigabitEthernet0/0
ip ospf authentication key-chain OSPF-KEY
۵. Summarization
Inter-Area (روی ABR)
router ospf 1
area 10 range 172.16.0.0 255.255.0.0
area 10 range 172.16.0.0 255.255.0.0 not-advertise ! برای فیلتر
External (روی ASBR)
router ospf 1
summary-address 10.0.0.0 255.255.0.0
۶. انواع خاص Area
Stub Area
روی همهٔ روترهای Area (از جمله ABR):
router ospf 1
area 10 stub
Totally Stubby (فقط روی ABR)
router ospf 1
area 10 stub no-summary
NSSA
router ospf 1
area 20 nssa
area 20 nssa default-information-originate ! برای ارسال Default
Totally NSSA (روی ABR)
router ospf 1
area 20 nssa no-summary
۷. Virtual Link
برای اتصال Area جدا از Backbone (روی دو ABR دو طرف Virtual Link):
router ospf 1
area 10 virtual-link 2.2.2.2
area 10 virtual-link 2.2.2.2 authentication message-digest
area 10 virtual-link 2.2.2.2 message-digest-key 1 md5 Secret
۸. Redistribution و Default Route
router ospf 1
redistribute connected subnets
redistribute static subnets
redistribute eigrp 100 metric 100 subnets
default-information originate
default-information originate always metric 10 metric-type 1
۹. دستورات Show و Verification
show ip ospf
show ip ospf neighbor
show ip ospf neighbor detail
show ip ospf interface
show ip ospf interface brief
show ip ospf database
show ip ospf database router
show ip ospf database network
show ip ospf database summary
show ip ospf database external
show ip ospf database nssa-external
show ip ospf border-routers
show ip route ospf
show ip protocols
show ip ospf virtual-links
۱۰. Troubleshooting رایج
Neighbor نمیآید → چک کردن این موارد:
- Area ID
- Subnet Mask
- Hello/Dead Timer
- Authentication
- MTU
- Network Type
- Passive Interface
گیر کردن در ExStart/Exchange → معمولاً به دلیل MTU mismatch است:
ip ospf mtu-ignore
دستورات Debug (با احتیاط)
debug ip ospf adj
debug ip ospf hello
debug ip ospf packet
