BGP Basics: เข้าใจ Border Gateway Protocol สำหรับ ISP

BGP Basics: เข้าใจ Border Gateway Protocol สำหรับ ISP

BGP (Border Gateway Protocol) เป็น routing protocol ที่ทำให้ internet ทำงานได้ เป็น protocol ที่ ISPs, data centers และองค์กรขนาดใหญ่ใช้แลกเปลี่ยน routing information ระหว่างกัน BGP เป็น “protocol ของ internet” ทุกครั้งที่คุณเข้าเว็บไซต์ BGP เป็นตัวกำหนดว่า traffic จะไปทางไหน ผ่าน ISP ไหน

BGP ต่างจาก interior routing protocols (OSPF, EIGRP) ตรงที่ BGP เป็น exterior gateway protocol ใช้ระหว่าง autonomous systems (AS) ที่ต่างกัน ในขณะที่ OSPF/EIGRP ใช้ภายใน AS เดียว BGP มีความซับซ้อนสูง configuration ผิดอาจทำให้ internet ในภูมิภาคล่มได้ บทความนี้จะอธิบายพื้นฐานของ BGP สำหรับ network engineers ที่ต้องทำงานกับ ISP

BGP vs IGP (OSPF/EIGRP)

คุณสมบัติ BGP OSPF/EIGRP
ประเภท Exterior Gateway Protocol (EGP) Interior Gateway Protocol (IGP)
ใช้ระหว่าง Autonomous Systems (AS) ภายใน AS เดียว
Algorithm Path Vector Link State (OSPF) / DUAL (EIGRP)
Metric Path attributes (AS-Path, Weight, etc.) Cost (OSPF) / Composite (EIGRP)
Scalability Internet scale (900,000+ routes) 1,000s of routes
Convergence ช้า (นาที) เร็ว (วินาที)
Transport TCP port 179 IP protocol 89 (OSPF) / IP protocol 88 (EIGRP)

Autonomous System (AS)

AS คืออะไร

Autonomous System คือกลุ่มของ networks ที่อยู่ภายใต้การบริหารจัดการเดียวกัน มี routing policy เดียวกัน แต่ละ AS มี AS Number (ASN) ที่ไม่ซ้ำกัน ASN เดิมเป็น 16-bit (1-65535) ปัจจุบันขยายเป็น 32-bit ตัวอย่าง: ISP แต่ละรายมี ASN ของตัวเอง, Google AS15169, Facebook AS32934, CAT AS9931, TRUE AS17552

iBGP vs eBGP

eBGP (External BGP)

eBGP คือ BGP session ระหว่าง routers ใน AS ที่ต่างกัน เช่น router ขององค์กร (AS65001) กับ router ของ ISP (AS9931) TTL = 1 (neighbors ต้องเชื่อมต่อโดยตรง หรือใช้ ebgp-multihop) AD (Administrative Distance) = 20

iBGP (Internal BGP)

iBGP คือ BGP session ระหว่าง routers ใน AS เดียวกัน ใช้กระจาย BGP routes ที่เรียนรู้จาก eBGP ไปให้ routers ตัวอื่นใน AS TTL = 255 (ไม่ต้อง directly connected) AD = 200 iBGP มี split-horizon rule: routes ที่เรียนจาก iBGP จะไม่ forward ไปยัง iBGP neighbor อื่น แก้ด้วย route reflector หรือ full-mesh iBGP

BGP Path Selection

ลำดับการเลือก Path (สำคัญมาก)

ลำดับ Attribute ค่าที่ต้องการ ใช้ทำอะไร
1 Weight (Cisco only) สูงกว่า Local preference ระดับ router
2 Local Preference สูงกว่า กำหนด preferred exit point จาก AS
3 Locally Originated ใช่ Routes ที่ originate จาก router นี้
4 AS-Path Length สั้นกว่า จำนวน AS ที่ต้องผ่าน ยิ่งสั้นยิ่งดี
5 Origin IGP > EGP > Incomplete วิธีที่ route ถูก inject เข้า BGP
6 MED ต่ำกว่า บอก neighbor ว่า prefer เข้าทาง link ไหน
7 eBGP over iBGP eBGP Prefer routes จาก external AS
8 Lowest IGP Metric ต่ำกว่า Nearest iBGP next-hop
9 Oldest Route เก่ากว่า Stability preference
10 Lowest Router ID ต่ำกว่า Tiebreaker

BGP ที่องค์กรต้องใช้

Multihoming (2 ISPs)

องค์กรที่มี internet จาก 2 ISPs (redundancy) ต้องใช้ BGP เพื่อ ประกาศ public IP ของตัวเองผ่านทั้ง 2 ISPs รับ full routing table หรือ default route จากทั้ง 2 ISPs กำหนด traffic engineering (prefer ISP ไหนสำหรับ outbound/inbound) failover อัตโนมัติเมื่อ ISP ใด ISP หนึ่งล่ม

สิ่งที่ต้องมี

ขอ ASN จาก APNIC (Asia Pacific) หรือได้รับจาก ISP (private ASN 64512-65534) ขอ PI (Provider Independent) IP address block จาก APNIC (ถ้าต้องการ IP ที่ไม่ผูกกับ ISP) หรือใช้ PA (Provider Assigned) IP จาก ISP router ที่รองรับ BGP (Cisco ISR, MikroTik, Juniper)

BGP Security

Route Hijacking

BGP route hijacking เกิดเมื่อ AS ประกาศ prefix ที่ไม่ใช่ของตัวเอง ทำให้ traffic ถูก redirect ไปยังที่ผิด เคยเกิดหลายครั้ง (Pakistan Telecom hijack YouTube 2008, China Telecom hijack 2019) ป้องกันด้วย RPKI (Resource Public Key Infrastructure) ที่ validate ว่า AS มีสิทธิ์ประกาศ prefix นั้นจริง

BGP MD5 Authentication

ใช้ MD5 password สำหรับ BGP neighbor session ป้องกัน unauthorized BGP session ป้องกัน TCP RST attack ที่พยายามตัด BGP session

Prefix Filtering

ใช้ prefix-list filter routes ที่รับจาก eBGP neighbor ไม่รับ bogon prefixes (RFC 1918, 0.0.0.0/8, etc.) ไม่รับ prefix ที่ยาวกว่า /24 (สำหรับ IPv4) กำหนด maximum-prefix limit ป้องกัน route leak ที่ทำให้ routing table เต็ม

ทิ้งท้าย: BGP คือ Foundation ของ Internet

BGP เป็น protocol ที่ทำให้ internet ทำงานได้ สำหรับองค์กรที่มี multihoming (2+ ISPs) BGP เป็นสิ่งจำเป็น เข้าใจ path selection process, iBGP/eBGP, security best practices แล้ว BGP ก็ไม่ได้ยากอย่างที่คิด

อ่านเพิ่มเติมเกี่ยวกับ OSPF Configuration และ SD-WAN ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com

จัดส่งรวดเร็วส่งด่วนทั่วประเทศ
รับประกันสินค้าเคลมง่าย มีใบรับประกัน
ผ่อนชำระได้บัตรเครดิต 0% สูงสุด 10 เดือน
สะสมแต้ม รับส่วนลดส่วนลดและคะแนนสะสม

© 2026 SiamLancard — จำหน่ายการ์ดแลน อุปกรณ์ Server และเครื่องพิมพ์ใบเสร็จ

SiamLancard
Logo
Free Forex EA Download — XM Signal · EA Forex ฟรี
iCafeForex.com - สอนเทรด Forex | SiamCafe.net
Shopping cart