
Routing Protocol คืออะไร? ทำไมต้องเปรียบเทียบ?
Routing Protocol คือโปรโตคอลที่ Router ใช้สื่อสารกัน เพื่อแลกเปลี่ยนข้อมูล Routing Table และหาเส้นทางที่ดีที่สุดไปยังปลายทาง Network Engineer ต้องเลือก Routing Protocol ที่เหมาะสมกับแต่ละสถานการณ์ เพราะแต่ละโปรโตคอลมีจุดเด่นจุดด้อยต่างกันอย่างชัดเจน
ในปี 2026 Routing Protocol ที่ใช้กันมากที่สุดในองค์กรและ ISP คือ OSPF, EIGRP และ BGP แต่ละตัวออกแบบมาสำหรับ Use case ที่ต่างกัน บทความนี้จะเปรียบเทียบทั้ง 3 แบบลงลึกทุกมิติ
ประเภทของ Routing Protocol
| ประเภท | Algorithm | ตัวอย่าง | ลักษณะ |
|---|---|---|---|
| Distance Vector | Bellman-Ford | RIP, EIGRP* | ส่ง Routing Table ให้เพื่อนบ้าน |
| Link-State | Dijkstra (SPF) | OSPF, IS-IS | สร้างแผนที่ Network ทั้งหมด |
| Path Vector | Best Path Selection | BGP | เลือกเส้นทางตาม AS Path + Attributes |
* EIGRP ใช้ DUAL (Diffusing Update Algorithm) ซึ่งเป็น Advanced Distance Vector หรือเรียกว่า Hybrid
OSPF (Open Shortest Path First) — ภาพรวม
OSPF คืออะไร?
OSPF เป็น Link-State Routing Protocol มาตรฐานเปิด (RFC 2328 สำหรับ OSPFv2, RFC 5340 สำหรับ OSPFv3) ใช้ Algorithm ของ Dijkstra หา Shortest Path First ไปยังทุก Network
หลักการทำงานของ OSPF
- Hello Protocol: Router ส่ง Hello Packet ค้นหาเพื่อนบ้าน (Neighbor) ผ่าน Multicast 224.0.0.5
- Neighbor Adjacency: สร้าง Adjacency กับเพื่อนบ้าน (2-Way → Exstart → Exchange → Loading → Full)
- LSA Flooding: แลกเปลี่ยน Link-State Advertisement (LSA) ทั้งหมดภายใน Area
- LSDB: สร้าง Link-State Database ที่เหมือนกันทุก Router ใน Area เดียวกัน
- SPF Calculation: ใช้ Dijkstra Algorithm คำนวณ Shortest Path Tree
- Routing Table: ใส่ Best routes ลงใน Routing Table
! ตัวอย่างการตั้งค่า OSPF
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0
network 10.0.0.0 0.0.0.3 area 0
network 172.16.0.0 0.0.255.255 area 1
passive-interface GigabitEthernet0/2
! ตรวจสอบ OSPF
show ip ospf neighbor
show ip ospf database
show ip route ospf
OSPF Metric — Cost
OSPF ใช้ Cost เป็น Metric โดยคำนวณจาก Bandwidth ของ Interface:
! OSPF Cost = Reference Bandwidth / Interface Bandwidth
! Default Reference Bandwidth = 100 Mbps (10^8)
! ตัวอย่าง Cost:
! FastEthernet (100 Mbps) → Cost = 100/100 = 1
! GigabitEthernet (1 Gbps) → Cost = 100/1000 = 1 (เท่ากัน! ปัญหา!)
! 10GigE (10 Gbps) → Cost = 100/10000 = 1 (ปัญหาเดียวกัน!)
! แก้ไข: เพิ่ม Reference Bandwidth
router ospf 1
auto-cost reference-bandwidth 100000 ! 100 Gbps
! ตอนนี้:
! FastEthernet → Cost = 100000/100 = 1000
! GigabitEthernet → Cost = 100000/1000 = 100
! 10GigE → Cost = 100000/10000 = 10
OSPF Area Design
| Area Type | LSA ที่รับ | ใช้เมื่อ |
|---|---|---|
| Backbone (Area 0) | ทุก LSA | ศูนย์กลาง ทุก Area ต้องเชื่อมกับ Area 0 |
| Normal Area | LSA 1,2,3,4,5 | Area ทั่วไป |
| Stub Area | LSA 1,2,3 (ไม่รับ 4,5) | ลด LSDB ไม่ต้องการ External routes |
| Totally Stub | LSA 1,2 + Default route | ลด LSDB มาก ใช้ Default route ออก Area |
| NSSA | LSA 1,2,3,7 (ไม่รับ 5) | Stub แต่มี External routes ภายใน (ASBR) |
! Stub Area
router ospf 1
area 2 stub
! Totally Stubby Area (ABR only)
router ospf 1
area 2 stub no-summary
! NSSA
router ospf 1
area 3 nssa
EIGRP (Enhanced Interior Gateway Routing Protocol) — ภาพรวม
EIGRP คืออะไร?
EIGRP เป็น Advanced Distance Vector Routing Protocol พัฒนาโดย Cisco (เดิมเป็น Cisco Proprietary แต่ตอนนี้เป็น Open Standard RFC 7868) ใช้ DUAL Algorithm ที่ Converge เร็วมาก
หลักการทำงานของ EIGRP
- Hello Protocol: ค้นหาเพื่อนบ้านผ่าน Multicast 224.0.0.10
- Neighbor Table: เก็บรายชื่อเพื่อนบ้านทั้งหมด
- Topology Table: เก็บเส้นทางทั้งหมดที่ได้รับจากเพื่อนบ้าน (ทั้ง Successor และ Feasible Successor)
- DUAL Algorithm: คำนวณ Successor (Best route) และ Feasible Successor (Backup route)
- Routing Table: ใส่ Successor routes เข้า Routing Table
! ตัวอย่างการตั้งค่า EIGRP (Classic mode)
router eigrp 100
network 192.168.1.0 0.0.0.255
network 10.0.0.0
no auto-summary
passive-interface GigabitEthernet0/2
! EIGRP Named Mode (แนะนำ)
router eigrp MY_EIGRP
address-family ipv4 unicast autonomous-system 100
network 192.168.1.0 0.0.0.255
network 10.0.0.0
af-interface default
passive-interface
exit-af-interface
af-interface GigabitEthernet0/0
no passive-interface
exit-af-interface
topology base
no auto-summary
exit-af-topology
! ตรวจสอบ EIGRP
show ip eigrp neighbors
show ip eigrp topology
show ip route eigrp
EIGRP Metric — Composite Metric
EIGRP ใช้ Composite Metric ที่ซับซ้อนกว่า OSPF:
! EIGRP Composite Metric Formula:
! Metric = [K1*BW + (K2*BW)/(256-Load) + K3*Delay] * [K5/(K4+Reliability)]
!
! Default K values: K1=1, K2=0, K3=1, K4=0, K5=0
! ดังนั้น Default Formula = BW + Delay
!
! BW = (10^7 / Bandwidth_kbps) * 256
! Delay = (Delay_in_10us) * 256
!
! Wide Metric (EIGRP Named Mode):
! Metric = (K1*BW_scaled + K3*Delay_scaled) * 65536/K6_scaled_BW
! ตรวจสอบ Metric
show ip eigrp topology 192.168.1.0 255.255.255.0
DUAL — Successor vs Feasible Successor
| คำศัพท์ | ความหมาย | หน้าที่ |
|---|---|---|
| Successor | เส้นทาง Best route (Metric ต่ำสุด) | ใส่ใน Routing Table |
| Feasible Distance (FD) | Metric จาก Local Router ไปยัง Destination | เปรียบเทียบเส้นทาง |
| Reported Distance (RD) | Metric จาก Neighbor ไปยัง Destination | ใช้ตรวจ Feasibility Condition |
| Feasible Successor (FS) | Backup route ที่ RD < FD ของ Successor | Failover ทันทีไม่ต้องคำนวณใหม่ |
! Feasibility Condition:
! ถ้า Reported Distance (RD) ของเพื่อนบ้าน < Feasible Distance (FD) ของ Successor
! → เพื่อนบ้านนั้นเป็น Feasible Successor (Backup route)
! → Failover ได้ทันทีภายใน Milliseconds!
! ตัวอย่าง:
! Successor: R2 → FD = 30720, RD = 28160
! Neighbor R3: RD = 25600 (25600 < 30720 ✓) → เป็น Feasible Successor
! Neighbor R4: RD = 33280 (33280 > 30720 ✗) → ไม่เป็น Feasible Successor
BGP (Border Gateway Protocol) — ภาพรวม
BGP คืออะไร?
BGP เป็น Path Vector Routing Protocol ที่ใช้เชื่อมต่อระหว่าง Autonomous Systems (AS) เรียกว่า Exterior Gateway Protocol (EGP) BGP version 4 (BGPv4 — RFC 4271) เป็นโปรโตคอลที่ทำให้ Internet ทำงานได้
iBGP vs eBGP
| คุณสมบัติ | iBGP (Internal BGP) | eBGP (External BGP) |
|---|---|---|
| AS | Peer อยู่ใน AS เดียวกัน | Peer อยู่คนละ AS |
| AD (Administrative Distance) | 200 | 20 |
| Next-Hop | ไม่เปลี่ยน (ต้อง set ด้วย next-hop-self) | เปลี่ยนเป็น IP ของ Peer |
| TTL | 255 (ผ่าน Router ได้) | 1 (ต้องเชื่อมตรง หรือ multihop) |
| Loop Prevention | ไม่ส่ง Route ที่เรียนจาก iBGP ให้ iBGP อื่น | ดูจาก AS_PATH |
| Full Mesh | ต้อง Full Mesh หรือใช้ Route Reflector | ไม่จำเป็น |
! ตัวอย่างการตั้งค่า BGP
router bgp 65001
bgp router-id 1.1.1.1
bgp log-neighbor-changes
! eBGP Neighbor (ต่าง AS)
neighbor 203.0.113.1 remote-as 65002
! iBGP Neighbor (AS เดียวกัน)
neighbor 10.0.0.2 remote-as 65001
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.2 next-hop-self
! Advertise Networks
network 192.168.0.0 mask 255.255.0.0
! Route Reflector (แทน Full Mesh)
neighbor 10.0.0.3 route-reflector-client
! ตรวจสอบ BGP
show ip bgp summary
show ip bgp
show ip bgp neighbors 203.0.113.1
BGP Path Selection Algorithm
BGP ไม่ได้ใช้ Metric แบบ OSPF/EIGRP แต่ใช้ Path Attributes ตัดสินตาม Priority:
- Weight (Cisco-specific, สูงสุดชนะ) — Local only
- Local Preference (สูงสุดชนะ) — iBGP
- Locally Originated (network/redistribute/aggregate ชนะ)
- AS_PATH shortest (สั้นสุดชนะ)
- Origin (IGP > EGP > Incomplete)
- MED (Multi-Exit Discriminator) (ต่ำสุดชนะ)
- eBGP > iBGP
- Closest IGP metric to Next-hop
- Oldest route
- Lowest Router ID
! ตั้งค่า BGP Path Attributes
router bgp 65001
! Weight (local only)
neighbor 203.0.113.1 weight 200
! Local Preference
neighbor 203.0.113.1 route-map SET_LP in
!
route-map SET_LP permit 10
set local-preference 200
! AS_PATH Prepending (ทำให้ path ยาวขึ้น เพื่อ "บอก" ให้คนอื่นไม่เลือกเส้นทางนี้)
route-map PREPEND permit 10
set as-path prepend 65001 65001 65001
! MED
route-map SET_MED permit 10
set metric 100
เปรียบเทียบ OSPF vs EIGRP vs BGP — ทุกมิติ
| คุณสมบัติ | OSPF | EIGRP | BGP |
|---|---|---|---|
| ประเภท | Link-State (IGP) | Advanced Distance Vector (IGP) | Path Vector (EGP) |
| Algorithm | Dijkstra (SPF) | DUAL | Best Path Selection |
| Metric | Cost (Bandwidth) | Composite (BW+Delay) | Path Attributes (AS_PATH etc.) |
| AD (Internal) | 110 | 90 | 200 (iBGP), 20 (eBGP) |
| Transport | IP Protocol 89 | IP Protocol 88 | TCP Port 179 |
| Convergence | ปานกลาง (SPF calculation) | เร็วมาก (Feasible Successor) | ช้า (Minutes — by design) |
| Scalability | ดี (ด้วย Area design) | ดี (ด้วย Stub, Summarization) | ดีมาก (รองรับ Full Internet Table) |
| Vendor | Open Standard (ทุก Vendor) | Cisco-centric (RFC 7868) | Open Standard (ทุก Vendor) |
| Full Internet Table | ไม่เหมาะ | ไม่เหมาะ | ออกแบบมาเพื่อสิ่งนี้ |
| Policy Control | จำกัด | จำกัด | ยืดหยุ่นมาก (Route-map, Community) |
| Hello Timer Default | 10 วินาที (Broadcast) | 5 วินาที | 60 วินาที |
| Dead Timer Default | 40 วินาที | 15 วินาที (3x Hello) | 180 วินาที |
| VLSM/CIDR | รองรับ | รองรับ | รองรับ |
| Authentication | MD5, SHA-256 | MD5, SHA-256 | MD5, TCP-AO |
| Load Balancing | Equal-cost (ECMP) | Equal + Unequal cost | Limited (multipath) |
Convergence — ความเร็วในการ Recover
EIGRP — Convergence เร็วที่สุด
! EIGRP Convergence:
! 1. Link ล่ม → ตรวจจับจาก Hello timeout (15 วินาที)
! หรือ Interface down detection (Milliseconds)
! 2. ถ้ามี Feasible Successor → Failover ทันที (Sub-second!)
! 3. ถ้าไม่มี FS → Active Query → Convergence 3-30 วินาที
!
! EIGRP เร็วเพราะ:
! - DUAL pre-compute Backup route (Feasible Successor)
! - ไม่ต้อง Recalculate ทั้งหมดเหมือน SPF
! - Partial update (ส่งเฉพาะ Route ที่เปลี่ยน)
OSPF — Convergence ปานกลาง
! OSPF Convergence:
! 1. Link ล่ม → Hello timeout (40 วินาที) หรือ BFD (Milliseconds)
! 2. LSA Flooding → Flood ไปทั้ง Area
! 3. SPF Calculation → คำนวณ Shortest Path ใหม่
! 4. Update Routing Table
!
! OSPF Convergence Tuning:
router ospf 1
timers throttle spf 50 200 5000 ! spf-start spf-hold spf-max-wait (ms)
timers throttle lsa all 0 200 5000
interface GigabitEthernet0/0
ip ospf hello-interval 1 ! ลด Hello เหลือ 1 วินาที
ip ospf dead-interval 3 ! Dead = 3 วินาที
! BFD (Bidirectional Forwarding Detection) — ตรวจจับ Link down ใน Milliseconds
interface GigabitEthernet0/0
bfd interval 100 min_rx 100 multiplier 3
router ospf 1
bfd all-interfaces
BGP — Convergence ช้า (By Design)
! BGP Convergence:
! 1. Hold Timer timeout (180 วินาที!) หรือ BFD
! 2. BGP ตั้งใจให้ Converge ช้า เพื่อ Stability
! 3. ถ้า Route flapping → Route Dampening (ยิ่งช้า)
!
! BGP Convergence Tuning:
router bgp 65001
neighbor 203.0.113.1 timers 10 30 ! keepalive 10, holdtime 30
! BFD
neighbor 203.0.113.1 fall-over bfd
! ทำไม BGP ช้า?
! - Internet มี 900,000+ Prefixes (2026)
! - ถ้า Converge เร็วเกินไป จะเกิด Route oscillation
! - BGP ใช้ MRAI (Minimum Route Advertisement Interval) 30 วินาที
! - Stability สำคัญกว่า Speed สำหรับ Internet scale
เลือก Routing Protocol ไหนดี? — Use Case Guide
Campus Network / Enterprise LAN → OSPF
! ทำไมเลือก OSPF สำหรับ Campus?
! ✓ Open Standard — ใช้กับ Cisco, Juniper, Arista, MikroTik
! ✓ Area Design — แบ่ง Campus เป็น Area ตามอาคาร/ชั้น
! ✓ Equal-Cost Load Balancing
! ✓ Fast Convergence ด้วย BFD
! ✓ Vendor Interoperability
!
! Design ตัวอย่าง:
! Area 0 (Backbone): Core switches
! Area 1: อาคาร A (Distribution + Access)
! Area 2: อาคาร B
! Area 3: Data Center
! NSSA: Branch office ที่มี Internet breakout
Cisco-Only WAN → EIGRP
! ทำไมเลือก EIGRP สำหรับ Cisco WAN?
! ✓ Convergence เร็วที่สุด (Feasible Successor)
! ✓ Unequal-Cost Load Balancing (variance)
! ✓ ใช้ Bandwidth น้อย (Partial update)
! ✓ Config ง่ายกว่า OSPF (ไม่ต้อง Area design)
!
! แต่ข้อจำกัด:
! ✗ Vendor support จำกัด (แม้จะเป็น RFC แล้ว)
! ✗ ถ้าจะเปลี่ยน Vendor ต้อง Migrate
!
! Unequal-Cost Load Balancing:
router eigrp 100
variance 2 ! ใช้เส้นทางที่ Metric ไม่เกิน 2x ของ Best route
WAN / ISP / Multi-AS → BGP
! ทำไมเลือก BGP สำหรับ WAN/ISP?
! ✓ ออกแบบมาเพื่อ Inter-AS routing
! ✓ Policy control ยืดหยุ่นมาก
! ✓ รองรับ Full Internet Table (900K+ routes)
! ✓ Path manipulation (AS_PATH prepend, MED, Local Pref)
! ✓ Community สำหรับ Tagging routes
!
! Use cases ที่ต้องใช้ BGP:
! - เชื่อมต่อ ISP (Multihoming)
! - MPLS VPN (MP-BGP)
! - Data Center Fabric (BGP EVPN)
! - SD-WAN underlay/overlay
! - Cloud interconnect (AWS Direct Connect, Azure ExpressRoute)
Migration ระหว่าง Routing Protocol
EIGRP → OSPF Migration
! Step 1: เพิ่ม OSPF ควบคู่กับ EIGRP
router ospf 1
router-id 1.1.1.1
network 0.0.0.0 255.255.255.255 area 0
! Step 2: ตรวจสอบว่า OSPF routes เข้ามาแล้ว
show ip route ospf
! EIGRP AD=90, OSPF AD=110 → EIGRP ยังชนะ
! Step 3: Redistribute (ถ้าจำเป็น)
router ospf 1
redistribute eigrp 100 subnets metric-type 1
! Step 4: เมื่อพร้อม ลบ EIGRP
! (ทำทีละ Router, ตรวจสอบ Connectivity ทุกครั้ง)
no router eigrp 100
! Step 5: ตรวจสอบ
show ip route
show ip ospf neighbor
traceroute 10.1.1.1
OSPF → BGP Migration (Data Center)
! Data Center ปี 2026 มีเทรนด์ใช้ BGP แทน OSPF (BGP Unnumbered)
! เพราะ:
! - ไม่ต้อง Area design
! - Equal-Cost Multipath (ECMP) ง่ายกว่า
! - ใช้ Community tagging
! - ไม่มี LSA flooding storm ตอน Network เปลี่ยนแปลง
! BGP Unnumbered (ใช้กับ FRRouting, Cumulus):
router bgp 65001
bgp bestpath as-path multipath-relax
neighbor fabric peer-group
neighbor fabric remote-as external
neighbor eth0 interface peer-group fabric
neighbor eth1 interface peer-group fabric
address-family ipv4 unicast
redistribute connected
maximum-paths 64
Hybrid Design — ใช้หลาย Protocol ร่วมกัน
! ตัวอย่าง Hybrid Design ขององค์กรขนาดใหญ่:
!
! Campus LAN: OSPF (Area-based design)
! ↕ Redistribution
! WAN Backbone: BGP (eBGP ระหว่าง Site)
! ↕ eBGP
! ISP/Internet: BGP (Multihoming)
! ↕ eBGP
! Data Center: BGP (EVPN/VXLAN) หรือ OSPF (Legacy)
!
! Redistribution Points (สำคัญ!):
router ospf 1
redistribute bgp 65001 subnets route-map BGP_TO_OSPF
router bgp 65001
redistribute ospf 1 route-map OSPF_TO_BGP
! ใช้ Route-map ป้องกัน Routing Loop!
route-map BGP_TO_OSPF permit 10
match tag 100
set metric 1000
set metric-type type-1
route-map BGP_TO_OSPF deny 20
route-map OSPF_TO_BGP permit 10
match tag 200
set community 65001:100
Scalability — รองรับ Network ขนาดไหน?
| ขนาด | OSPF | EIGRP | BGP |
|---|---|---|---|
| Router 10-50 ตัว | สบายมาก | สบายมาก | Overkill |
| Router 50-200 ตัว | ดี (ต้อง Area design ดี) | ดี | เหมาะ (ถ้า Multi-AS) |
| Router 200-1000 ตัว | ต้อง Area design ระวัง | ดี (Query scope จำกัด) | เหมาะมาก |
| Router 1000+ ตัว | ต้อง Hierarchical design | ต้อง Summarization | ออกแบบมาเพื่อสิ่งนี้ |
| Internet Scale | ไม่เหมาะ | ไม่เหมาะ | ใช้อยู่จริง (900K+ routes) |
Security — การป้องกัน Routing Attack
! OSPF Authentication
interface GigabitEthernet0/0
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 OSPF_SECRET_KEY
! EIGRP Authentication (Named Mode)
router eigrp MY_EIGRP
address-family ipv4 unicast autonomous-system 100
af-interface GigabitEthernet0/0
authentication mode hmac-sha-256 EIGRP_KEY
exit-af-interface
! BGP Authentication
router bgp 65001
neighbor 203.0.113.1 password BGP_SECRET_KEY
! BGP RPKI (Resource Public Key Infrastructure) — ป้องกัน Route Hijacking
router bgp 65001
rpki server tcp 10.0.0.100 port 3323
bgp bestpath prefix-validate
! ตรวจสอบ RPKI
show ip bgp rpki table
อนาคต Routing Protocol — BGP Everywhere?
ในปี 2026 มีเทรนด์ชัดเจนที่ BGP กำลังขยายตัว เข้าไปในทุกส่วนของ Network:
| พื้นที่ | เดิม | เทรนด์ 2026 |
|---|---|---|
| Data Center Fabric | OSPF/IS-IS | BGP (Unnumbered, EVPN) |
| SD-WAN | OSPF/EIGRP | BGP (Overlay routing) |
| Cloud Networking | Proprietary | BGP (VPC peering, Transit Gateway) |
| Segment Routing | IS-IS/OSPF | BGP (SRv6, BGP-LS) |
| Campus (ใหม่) | OSPF | เริ่มมี BGP (Cisco SD-Access) |
ทำไม BGP ถึงขยายตัว?
- Policy-rich: Community, Extended Community, Large Community ให้ Tagging ได้ยืดหยุ่น
- Multi-protocol: MP-BGP รองรับ IPv4, IPv6, EVPN, VPNv4, Flowspec
- Automation-friendly: BGP community เหมาะกับ Programmable network
- No flooding: ไม่มี LSA flooding storm เหมือน OSPF/IS-IS
- Proven scale: ทำงานบน Internet ที่ใหญ่ที่สุดในโลกมา 30+ ปี
สรุป — OSPF vs EIGRP vs BGP 2026
| Scenario | แนะนำ | เหตุผล |
|---|---|---|
| Campus LAN | OSPF | Open Standard, Area design, Multi-vendor |
| Cisco-Only WAN | EIGRP | Convergence เร็ว, Config ง่าย, Unequal LB |
| ISP / Internet | BGP | Inter-AS, Policy control, Scale |
| Multi-Vendor WAN | OSPF + BGP | OSPF ภายใน + BGP ระหว่าง Site |
| Data Center Fabric | BGP (EVPN) | No flooding, Community, ECMP |
| Cloud Hybrid | BGP | AWS/Azure/GCP ใช้ BGP |
ไม่มี Routing Protocol ไหนที่ “ดีที่สุด” สำหรับทุกกรณี สิ่งสำคัญคือ เข้าใจจุดแข็ง จุดอ่อน และ Use case ของแต่ละตัว แล้วเลือกใช้ให้ตรงกับ Network ที่คุณดูแล ในปี 2026 Network Engineer ควรเชี่ยวชาญทั้ง 3 โปรโตคอล เพราะ Enterprise Network สมัยใหม่มักใช้ Hybrid design ที่ผสมหลาย Protocol เข้าด้วยกัน