หลังจากเข้าใจพื้นฐาน OSPF ตั้งแต่ Router ID, Hello Packet, LSA, LSDB, SPF และ Area 0 แล้ว ขั้นต่อไปคือการทำความเข้าใจว่า OSPF Router สองตัวพัฒนาความสัมพันธ์ จากการค้นพบกันจนกลายเป็น Full Adjacency ได้อย่างไร
หัวใจของกระบวนการนี้คือ OSPF Neighbor States ตั้งแต่ Down, Init, 2-Way, ExStart, Exchange, Loading ไปจนถึง Full รวมถึงบทบาทของ DR และ BDR บน Multiaccess Network เช่น Ethernet
ความเข้าใจเรื่องนี้มีประโยชน์โดยตรง ต่อการ Troubleshoot ปัญหา OSPF Neighbor ไม่ขึ้น, ค้างที่ 2-Way, ExStart, Exchange หรือ Loading
สารบัญ
- OSPF Neighbor คืออะไร?
- Neighbor กับ Adjacency ต่างกันอย่างไร?
- OSPF Neighbor States
- Down State
- Init State
- 2-Way State
- ExStart State
- Exchange State
- Loading State
- Full State
- OSPF Packet Types
- DR คืออะไร?
- BDR คืออะไร?
- DR/BDR Election
- OSPF Priority
- DROTHER คืออะไร?
- OSPF Network Type
- Cisco Lab
- Troubleshooting Neighbor States
- Command Cheat Sheet
- FAQ
ภาค 1: OSPF Neighbor และ Adjacency
OSPF Neighbor คืออะไร?
OSPF Router ใช้ Hello Packet เพื่อค้นหา OSPF Router อื่น บน Link ที่เกี่ยวข้อง
R1 R2
| |
|------- Hello ----------->|
| |
|<------ Hello ------------|
| |
+------ Neighbor ----------+
เมื่อ Parameters ที่จำเป็น สำหรับการเป็น Neighbor เข้ากันได้ตาม OSPF Rules Router จะสามารถพัฒนา Neighbor Relationship ต่อไป
ตรวจสอบด้วย:
R1# show ip ospf neighbor
Neighbor กับ Adjacency ต่างกันอย่างไร?
คำว่า Neighbor และ Adjacency ไม่ควรถูกใช้แทนกันทุกกรณี
Neighbor คือ Router ที่ OSPF ค้นพบและรักษา Neighbor Relationship
Adjacency เป็นความสัมพันธ์ ในระดับที่ Routers ดำเนินกระบวนการ Synchronize Link-State Database ตามที่ OSPF ต้องการ
Neighbor
|
v
2-Way
|
| Adjacency required?
|
+---+---+
| |
No Yes
| |
v v
2-Way ExStart
|
v
Exchange
|
v
Loading
|
v
Full
ภาค 2: OSPF Neighbor States
OSPF Neighbor มี State อะไรบ้าง?
ลำดับหลักที่ควรรู้คือ:
Down
|
v
Init
|
v
2-Way
|
v
ExStart
|
v
Exchange
|
v
Loading
|
v
Full
OSPF ยังมี Attempt State ในบาง Network Type/Scenario แต่สำหรับ Ethernet Lab พื้นฐาน มักเน้น States ด้านบน
1. Down State
Down เป็นสถานะเริ่มต้น ที่ยังไม่มี Hello จาก Neighbor ที่เกี่ยวข้อง ถูกประมวลผลใน Neighbor Relationship
R1 R2
No valid Hello
processed yet
Neighbor State
=
DOWN
หาก Neighbor ไม่เกิดเลย ควรตรวจ:
- Interface Up/Up หรือไม่
- IP Address/Subnet ถูกต้องหรือไม่
- OSPF เปิดบน Interface หรือไม่
- Interface ถูกตั้ง Passive หรือไม่
- Area ถูกต้องหรือไม่
- OSPF Packets ถูก Block หรือไม่
2. Init State
Init หมายถึง Router ได้รับ Hello จาก Neighbor แต่ยังไม่เห็น Router ID ของตัวเองอยู่ใน Neighbor List ของ Hello ที่ได้รับ
R1 R2
| |
|<------- Hello -----------|
| |
| R1 receives R2 Hello |
| |
| But R1 does not see |
| its own Router ID |
| in R2 neighbor list |
| |
v
INIT
ถ้า Neighbor ค้างที่ Init ควรพิจารณาปัญหา การสื่อสาร OSPF แบบ Two-Way รวมถึง Network Connectivity และ Packet Delivery
3. 2-Way State
เมื่อ R1 ได้รับ Hello จาก R2 และพบ Router ID ของตัวเอง อยู่ใน Neighbor List ภายใน Hello ของ R2 ความสัมพันธ์ได้เข้าสู่ Two-Way Communication
R1 R2
| |
|------- Hello ----------->|
| |
|<------ Hello ------------|
| |
| Both routers see |
| each other |
| |
+-------- 2-WAY -----------+
บน Broadcast Multiaccess Network นี่เป็นจุดสำคัญของ DR/BDR Election และการตัดสินใจว่า Neighbor คู่ใดต้องพัฒนา ไปเป็น Full Adjacency
4. ExStart State
หาก Router ต้องสร้าง Adjacency จะเข้าสู่ ExStart เพื่อเริ่มกระบวนการ Database Synchronization
Routers จะกำหนดบทบาท Master/Slave สำหรับ Database Description Exchange โดย Router ID มีส่วนในการกำหนดบทบาทนี้
R1 R2
| |
| Adjacency needed |
| |
|<----- ExStart -------->|
| |
| Determine Master/Slave |
| |
v v
ค้างที่ ExStart ต้องสงสัยอะไร?
หนึ่งในปัญหาที่พบบ่อยคือ MTU mismatch แต่ไม่ใช่สาเหตุเดียว
ควรตรวจ:
- Interface MTU
- Duplicate Router ID
- Link Stability
- Packet Loss
- Network Type
- Platform/Software Issues
5. Exchange State
ใน Exchange State Routers แลกเปลี่ยน Database Description หรือ DBD/DD Packets เพื่อสรุปข้อมูล LSDB ที่แต่ละ Router มีอยู่
R1 R2
| |
|------- DBD/DD ----------->|
|<------ DBD/DD ------------|
| |
| Compare database summary |
| |
v v
DBD ไม่ได้หมายถึง การส่งรายละเอียด LSA ทั้งหมด ใน Packet เดียว แต่เป็นข้อมูล Summary ที่ใช้ตรวจว่าฝั่งใด ต้องร้องขอ Link-State Information เพิ่มเติม
6. Loading State
เมื่อ Router พบว่า LSDB ของตัวเอง ยังขาด Link-State Information จะร้องขอข้อมูลที่ต้องการ
R1 R2
| |
|------ LSR ----------------->|
| |
|<----- LSU ------------------|
| |
|------ LSAck --------------->|
| |
v v
กระบวนการเกี่ยวข้องกับ:
- Link-State Request — LSR
- Link-State Update — LSU
- Link-State Acknowledgment — LSAck
7. Full State
Full หมายถึง OSPF Adjacency มี Database Synchronization ตามที่ต้องการสำหรับ Neighbor คู่นั้น
R1 ===================== R2
FULL
LSDB synchronized
for the adjacency
ตรวจ:
R1# show ip ospf neighbor
อาจเห็น:
Neighbor ID Pri State
2.2.2.2 1 FULL/DR
3.3.3.3 1 FULL/BDR
ภาค 3: OSPF Packet Types
OSPF มี Packet Type อะไรบ้าง?
| Type | ชื่อ | หน้าที่หลัก |
|---|---|---|
| 1 | Hello | Neighbor Discovery และรักษา Neighbor Relationship |
| 2 | Database Description — DBD/DD | แลกเปลี่ยน Summary ของ Link-State Database |
| 3 | Link-State Request — LSR | ร้องขอ Link-State Information |
| 4 | Link-State Update — LSU | ส่ง LSAs |
| 5 | Link-State Acknowledgment — LSAck | Acknowledge การรับ LSA |
จำเป็น Flow:
Hello
|
v
Neighbor
|
v
DBD
|
v
LSR
|
v
LSU
|
v
LSAck
|
v
LSDB Synchronization
ภาค 4: DR, BDR และ DROTHER
DR คืออะไร?
DR — Designated Router เป็น OSPF Router ที่ได้รับเลือกให้มีบทบาทสำคัญ บน Multiaccess Segment บาง Network Types เช่น Broadcast Ethernet
สมมติ:
R1
|
|
R2 ---SW--- R3
|
|
R4
Router ทั้ง 4 ตัว อยู่ใน Ethernet Broadcast Domain เดียวกัน
หากทุก Router สร้าง Full Adjacency กับทุก Router โดยตรง จำนวน Adjacencies จะเพิ่มอย่างรวดเร็ว เมื่อจำนวน Router เพิ่มขึ้น
OSPF จึงใช้ DR/BDR เพื่อช่วยจัดโครงสร้าง Adjacency และ LSA Exchange บน Segment ประเภทนี้
BDR คืออะไร?
BDR — Backup Designated Router เป็น Router สำรอง สำหรับบทบาท DR บน Segment
DR
|
|
+------+------+
| | |
R1 BDR R3
หาก DR ไม่สามารถทำหน้าที่ได้ BDR สามารถเข้ารับบทบาท DR ตาม OSPF Election Behavior
DROTHER คืออะไร?
Router บน Segment ที่ไม่ได้เป็น DR หรือ BDR เรียกโดยทั่วไปว่า DROTHER
DR
/ | \
/ | \
/ | \
DROTHER BDR DROTHER
DROTHER จะสร้าง Full Adjacency กับ DR และ BDR แต่ DROTHER สองตัว ไม่จำเป็นต้องสร้าง Full Adjacency ต่อกันบน Broadcast Segment
จึงอาจเห็น:
DROTHER ---- DROTHER
State: 2-WAY
และนี่อาจเป็น พฤติกรรมปกติ ไม่ใช่ Fault
DR/BDR Election ทำงานอย่างไร?
ปัจจัยสำคัญในการเลือก DR และ BDR ได้แก่:
- OSPF Interface Priority
- Router ID เมื่อ Priority เท่ากัน
แนวคิด:
Highest eligible
OSPF Interface Priority
|
v
DR/BDR Election
If Priority ties
|
v
Router ID considered
ค่า Priority 0 ทำให้ Interface ไม่เข้าร่วมเป็น Candidate สำหรับ DR/BDR บน Network Type ที่ใช้ Election
กำหนด OSPF Priority บน Cisco
ตัวอย่าง:
R1(config)# interface gigabitEthernet 0/0
R1(config-if)# ip ospf priority 200
R2:
R2(config)# interface gigabitEthernet 0/0
R2(config-if)# ip ospf priority 100
R3:
R3(config)# interface gigabitEthernet 0/0
R3(config-if)# ip ospf priority 0
แนวคิด:
R1 Priority 200
R2 Priority 100
R3 Priority 0
R3
=
Not eligible for DR/BDR
ทำไม Router Priority สูงกว่า แต่ไม่ได้เป็น DR?
สมมติ R2 เป็น DR อยู่แล้ว:
R2
Priority 100
Role = DR
จากนั้น R1 เข้ามาทีหลัง:
R1
Priority 200
R1 ไม่ได้แย่งตำแหน่ง DR โดยอัตโนมัติ เพียงเพราะ Priority สูงกว่า
Existing DR
|
v
continues as DR
Higher-priority router
joins later
|
v
does not automatically
preempt current DR
นี่เป็นจุดสำคัญมาก เมื่อทำ Cisco Lab เพราะผล Election อาจไม่ตรงกับที่คาด หาก Routers ถูกเปิด หรือ OSPF ถูกเริ่ม คนละเวลา
DR/BDR มีในทุก OSPF Network หรือไม่?
ไม่ใช่ การเลือก DR/BDR ขึ้นอยู่กับ OSPF Network Type
| Network Type | DR/BDR | หมายเหตุ |
|---|---|---|
| Broadcast | มี | พบได้ทั่วไปบน Ethernet |
| NBMA | มี | มีพฤติกรรมเฉพาะของ Network Type |
| Point-to-Point | ไม่มี | มีเพียงสอง Endpoint ในแนวคิด Point-to-Point |
| Point-to-Multipoint | โดยทั่วไปไม่มี DR/BDR | Behavior แตกต่างจาก Broadcast |
ตรวจ Network Type:
show ip ospf interface
ภาค 5: Cisco OSPF DR/BDR Lab
Lab: OSPF Routers บน Ethernet Segment เดียวกัน
Topology:
R1
10.0.0.1
|
|
|
R2 -------SW------- R3
10.0.0.2 10.0.0.3
|
|
R4
10.0.0.4
Network:
10.0.0.0/24
OSPF:
Area 0
R1
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config)# interface gigabitEthernet 0/0
R1(config-if)# ip address 10.0.0.1 255.255.255.0
R1(config-if)# ip ospf 1 area 0
R1(config-if)# ip ospf priority 200
R1(config-if)# no shutdown
R2
R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config)# interface gigabitEthernet 0/0
R2(config-if)# ip address 10.0.0.2 255.255.255.0
R2(config-if)# ip ospf 1 area 0
R2(config-if)# ip ospf priority 100
R2(config-if)# no shutdown
R3
R3(config)# router ospf 1
R3(config-router)# router-id 3.3.3.3
R3(config)# interface gigabitEthernet 0/0
R3(config-if)# ip address 10.0.0.3 255.255.255.0
R3(config-if)# ip ospf 1 area 0
R3(config-if)# ip ospf priority 1
R3(config-if)# no shutdown
R4
R4(config)# router ospf 1
R4(config-router)# router-id 4.4.4.4
R4(config)# interface gigabitEthernet 0/0
R4(config-if)# ip address 10.0.0.4 255.255.255.0
R4(config-if)# ip ospf 1 area 0
R4(config-if)# ip ospf priority 0
R4(config-if)# no shutdown
ตรวจ Neighbor
R3# show ip ospf neighbor
ผลจริงขึ้นอยู่กับ ลำดับและเวลาที่ Election เกิดขึ้น
หากเริ่ม Election ใหม่ ภายใต้เงื่อนไข Lab ที่ควบคุม และ Routers พร้อมกันตามที่ออกแบบ Priority จะมีบทบาทสำคัญ ต่อการเลือก DR/BDR
ตรวจบทบาท DR/BDR
R1# show ip ospf interface gigabitEthernet 0/0
ตรวจข้อมูล เช่น:
State
Designated Router
Backup Designated Router
Router Priority
Hello Timer
Dead Timer
Network Type
Cost
ภาค 6: Troubleshooting OSPF Neighbor States
Neighbor ไม่ Full ควรตรวจอย่างไร?
ไม่ควรเริ่มด้วยการ Clear OSPF ทันที แต่ควรดูว่า Neighbor อยู่ State ใดก่อน
show ip ospf neighbor
จากนั้น Troubleshoot ตาม State:
กรณี 1 — ไม่มี Neighbor
ตรวจ:
show ip interface brief
show ip ospf interface brief
show ip protocols
ตรวจ:
- Interface
- IP/Subnet
- OSPF Enabled
- Area
- Passive Interface
- Authentication
- ACL/Control Plane Filtering
กรณี 2 — INIT
Router ได้รับ Hello แต่ Two-Way Communication ยังไม่สมบูรณ์
ตรวจ:
- One-way communication
- Packet filtering
- Layer 2 connectivity
- Multicast handling
- Link instability
กรณี 3 — 2-WAY
ก่อนแก้ Configuration ให้ถามว่า:
Is this a Broadcast Segment?
Are both routers DROTHER?
ถ้าใช่ 2-Way อาจเป็น State ปกติ
กรณี 4 — ExStart / Exchange
ตรวจ:
show interfaces
show ip ospf interface
show ip ospf neighbor detail
เน้นตรวจ:
- MTU mismatch
- Duplicate Router ID
- Packet Loss
- Link instability
- Network Type
- Software/Platform behavior
กรณี 5 — Loading
ตรวจ:
- LSR/LSU Exchange
- LSDB
- Packet Loss
- Link Stability
- Logs
show ip ospf database
show logging
กรณี 6 — FULL แต่ไม่มี Route
อย่าแก้ Neighbor เพราะ Adjacency อาจทำงานถูกต้องแล้ว
ตรวจ:
show ip ospf database
show ip route ospf
show ip protocols
show ip route
จากนั้นตรวจ:
- Prefix ถูก Advertise หรือไม่
- LSA มีอยู่หรือไม่
- Route Filtering หรือไม่
- มี Route Source อื่นแข่งขันหรือไม่
- มี Prefix ที่ Specific กว่าหรือไม่
ตัวอย่าง MTU Mismatch
R1:
R1# show interfaces gigabitEthernet 0/0
สมมติ:
MTU 1500 bytes
R2:
R2# show interfaces gigabitEthernet 0/0
สมมติ:
MTU 1400 bytes
MTU ที่ไม่สอดคล้องกัน เป็นหนึ่งในสาเหตุที่ควรตรวจ เมื่อ Adjacency มีปัญหา บริเวณ ExStart/Exchange
Hello/Dead Timer Mismatch
ตรวจ:
show ip ospf interface gigabitEthernet 0/0
หาก Parameters ที่จำเป็น ไม่ Compatible กัน Neighbor Relationship อาจไม่เกิดขึ้นตามที่ต้องการ
ตัวอย่างการกำหนด Timer:
interface gigabitEthernet 0/0
ip ospf hello-interval 10
ip ospf dead-interval 40
Area Mismatch
R1:
interface gigabitEthernet 0/0
ip ospf 1 area 0
R2:
interface gigabitEthernet 0/0
ip ospf 1 area 1
Routers บน Link นี้ จะไม่สร้าง OSPF Adjacency ตามที่ต้องการ เนื่องจาก Area Configuration ไม่สอดคล้องกัน
Duplicate Router ID
Router ID ควร Unique ภายใน OSPF Routing Domain
ตัวอย่าง Configuration ที่ผิด:
R1
router ospf 1
router-id 1.1.1.1
R2
router ospf 1
router-id 1.1.1.1
ควรกำหนด Router ID ให้ไม่ซ้ำกัน
R1 = 1.1.1.1
R2 = 2.2.2.2
R3 = 3.3.3.3
Workflow สำหรับ Troubleshoot OSPF
1. Physical / Interface
|
v
2. IP Address / Subnet
|
v
3. Direct Ping
|
v
4. OSPF Enabled?
|
v
5. Area
|
v
6. Hello / Dead Timer
|
v
7. Authentication
|
v
8. Network Type
|
v
9. Router ID
|
v
10. Neighbor State
|
v
11. MTU
|
v
12. LSDB
|
v
13. Routing Table
|
v
14. End-to-End Test
การตรวจตามลำดับ ช่วยลดการเปลี่ยน Configuration โดยไม่จำเป็น และช่วยแยกว่า ปัญหาอยู่ที่ Layer 1, Layer 2, Layer 3 หรือ OSPF Control Plane
Cisco OSPF Command Cheat Sheet
| Command | ใช้ตรวจอะไร? |
|---|---|
show ip ospf neighbor |
Neighbor, State และ DR/BDR Role |
show ip ospf neighbor detail |
Neighbor Information แบบละเอียด |
show ip ospf interface |
Area, Cost, Timer, Network Type, DR/BDR |
show ip ospf interface brief |
OSPF Interface Summary |
show ip ospf |
OSPF Process และ Router ID |
show ip ospf database |
Link-State Database |
show ip route ospf |
OSPF Routes |
show ip protocols |
Routing Protocol Configuration |
show ip interface brief |
Interface และ IP Status |
show interfaces |
Interface, MTU, Errors และ Link Details |
show logging |
ตรวจ Log ที่เกี่ยวข้อง |
ping |
ทดสอบ Reachability |
คำถามที่พบบ่อย — FAQ
OSPF Neighbor State ปกติต้องเป็น Full เสมอหรือไม่?
ไม่เสมอไป บน Broadcast Multiaccess Network DROTHER Routers สองตัว สามารถอยู่ใน 2-Way State โดยเป็นพฤติกรรมปกติ
OSPF ค้างที่ 2-Way แปลว่ามีปัญหาหรือไม่?
ต้องตรวจ Network Type และ DR/BDR Role ก่อน หากเป็น DROTHER-to-DROTHER บน Broadcast Segment 2-Way สามารถเป็น State ปกติ
OSPF ค้างที่ ExStart ควรตรวจอะไร?
ควรตรวจ MTU, Duplicate Router ID, Network Type, Packet Loss, Link Stability และ Platform Behavior โดย MTU mismatch เป็นหนึ่งในสาเหตุที่พบบ่อย
DR คืออะไร?
DR หรือ Designated Router เป็น Router ที่ได้รับเลือก ให้มีบทบาทสำคัญในการจัดการ OSPF Adjacency และ Link-State Exchange บน Multiaccess Network Type ที่ใช้ DR/BDR
BDR คืออะไร?
BDR หรือ Backup Designated Router เป็น Router สำรอง สำหรับบทบาท DR บน Segment
DROTHER คืออะไร?
เป็น Router บน OSPF Segment ที่ไม่ได้เป็น DR หรือ BDR
อะไรเป็นตัวกำหนด DR และ BDR?
OSPF Interface Priority เป็นปัจจัยหลักในการ Election และเมื่อ Priority เท่ากัน Router ID จะถูกใช้ ในการตัดสินตาม Election Rules
Priority 0 หมายความว่าอะไร?
Interface ที่มี OSPF Priority 0 จะไม่มีสิทธิ์เป็น DR หรือ BDR บน Network Type ที่มี DR/BDR Election
ถ้าเพิ่ม Priority ให้สูงที่สุด จะกลายเป็น DR ทันทีหรือไม่?
ไม่ DR/BDR Election มีลักษณะ Non-Preemptive Router ที่เข้ามาภายหลัง จะไม่ยึดตำแหน่ง DR จาก DR ปัจจุบันโดยอัตโนมัติ เพียงเพราะมี Priority สูงกว่า
Point-to-Point OSPF ต้องมี DR/BDR หรือไม่?
ไม่ OSPF Point-to-Point Network Type ไม่ต้องทำ DR/BDR Election
Neighbor เป็น Full แล้ว แต่ Ping ปลายทางไม่ได้เพราะอะไร?
Full State ยืนยัน OSPF Adjacency ในบริบทนั้น แต่ End-to-End Communication ยังขึ้นกับ Routing Table, Return Route, ACL, Firewall, Interface และ Endpoint
สรุป
OSPF Neighbor Relationship ไม่ได้เปลี่ยนจาก Down ไป Full ในขั้นตอนเดียว แต่ผ่านหลาย States เพื่อค้นพบ Neighbor และ Synchronize Link-State Database
DOWN
|
v
INIT
|
v
2-WAY
|
v
EXSTART
|
v
EXCHANGE
|
v
LOADING
|
v
FULL
Packet Types ที่สัมพันธ์ กับกระบวนการ ได้แก่:
Hello
|
v
DBD
|
v
LSR
|
v
LSU
|
v
LSAck
บน Broadcast Multiaccess Network OSPF ใช้ DR และ BDR เพื่อลดความจำเป็น ในการสร้าง Full Adjacency ระหว่าง Router ทุกคู่
DR
/ | \
/ | \
DROTHER BDR DROTHER
DROTHER <----> DROTHER
2-WAY
DROTHER <----> DR
FULL
DROTHER <----> BDR
FULL
สิ่งสำคัญในการ Troubleshoot คืออย่าตีความ State โดยแยกออกจาก Network Type และ DR/BDR Role
บทความลำดับต่อไปควรเข้าสู่ OSPF LSA และ LSDB: Router LSA, Network LSA, Summary LSA, External LSA และการสร้าง OSPF Topology Database เพื่ออธิบายว่าหลังจาก Neighbor เป็น Full แล้ว Router แลกเปลี่ยนข้อมูล Topology และสร้าง Route อย่างไร
Share your thoughts here
Join the conversation and share your perspective on this article.