Home » BGP Route Filtering: Prefix Lists, Route Maps และ Communities
BGP Route Filtering: Prefix Lists, Route Maps และ Communities
BGP Route Filtering: Prefix Lists, Route Maps และ Communities
BGP Route Filtering เป็นทักษะสำคัญสำหรับ network engineers ที่ดูแล BGP peering การ filter routes ที่รับเข้า (inbound) และส่งออก (outbound) อย่างถูกต้องป้องกัน route leaks, hijacks และช่วยให้ routing table สะอาด Prefix lists, route maps และ BGP communities เป็นเครื่องมือหลักสำหรับ BGP filtering
BGP route leak เป็น สาเหตุหลักของ internet outages ขนาดใหญ่ หลายครั้ง เช่น Facebook outage 2021, Cloudflare outage 2022 การ filter BGP routes อย่างถูกต้องป้องกันปัญหาเหล่านี้ ทั้ง ISPs และ enterprises ต้อง implement strict filtering
BGP Filtering Tools
| Tool |
ใช้ทำอะไร |
ความละเอียด |
| Prefix List |
Filter ตาม prefix + prefix length |
Network + mask (e.g., 10.0.0.0/8 le 24) |
| AS-Path Filter |
Filter ตาม AS path (regex) |
AS numbers in path |
| Route Map |
Complex filtering + modification |
Match multiple criteria + set attributes |
| Community |
Tag routes สำหรับ policy |
ASN:value (e.g., 65000:100) |
| ACL/Distribute List |
Legacy filtering (ไม่แนะนำ) |
IP address + wildcard mask |
Prefix List
| Feature |
รายละเอียด |
| Match Prefix |
Match exact network + mask |
| ge (greater-equal) |
Match prefix length ≥ value |
| le (less-equal) |
Match prefix length ≤ value |
| ge + le combination |
Match prefix length range (ge X le Y) |
| Implicit Deny |
ท้าย prefix list มี implicit deny all |
| ตัวอย่าง |
ip prefix-list FILTER permit 10.0.0.0/8 le 24 → match 10.x.x.x with /8 to /24 |
Route Map
| Feature |
รายละเอียด |
| Structure |
Sequence of entries (permit/deny) with match + set clauses |
| Match Clause |
match ip address prefix-list, match as-path, match community |
| Set Clause |
set local-preference, set weight, set community, set metric |
| Continue |
Process next entry even if matched (optional) |
| Implicit Deny |
ท้าย route map มี implicit deny all |
| ใช้ที่ |
neighbor X route-map NAME in/out, redistribute |
BGP Communities
| Type |
Format |
ใช้สำหรับ |
| Standard |
ASN:value (e.g., 65000:100) |
Tag routes สำหรับ policy decisions |
| Extended |
Type:ASN:value |
RT (Route Target), SoO สำหรับ VPN |
| Large |
ASN:value1:value2 |
4-byte ASN support |
| Well-Known: NO_EXPORT |
community no-export |
ไม่ advertise ออก confederation/AS |
| Well-Known: NO_ADVERTISE |
community no-advertise |
ไม่ advertise ให้ neighbor ใดเลย |
| Well-Known: LOCAL_AS |
community local-AS |
ไม่ advertise ออก local AS |
Common Filtering Scenarios
| Scenario |
Tool |
วิธีทำ |
| Block default route |
Prefix list |
deny 0.0.0.0/0 |
| Accept customer routes only |
Prefix list + AS-path |
Match customer prefixes + AS-path ≤ 2 |
| Block bogon prefixes |
Prefix list |
Deny RFC 1918, RFC 5737, etc. |
| Set local-pref for primary path |
Route map |
match community PRIMARY → set local-pref 200 |
| Blackhole routing |
Community |
Send community BLACKHOLE (65535:666) to upstream |
| Limit prefix count |
maximum-prefix |
neighbor X maximum-prefix 1000 warning-only |
Bogon Filtering
| Prefix |
Description |
| 0.0.0.0/8 |
“This” network |
| 10.0.0.0/8 |
RFC 1918 private |
| 100.64.0.0/10 |
Carrier-grade NAT (RFC 6598) |
| 127.0.0.0/8 |
Loopback |
| 169.254.0.0/16 |
Link-local |
| 172.16.0.0/12 |
RFC 1918 private |
| 192.168.0.0/16 |
RFC 1918 private |
| 224.0.0.0/4 |
Multicast |
| 240.0.0.0/4 |
Reserved |
RPKI (Resource Public Key Infrastructure)
| Feature |
รายละเอียด |
| คืออะไร |
Cryptographic validation ว่า AS ได้รับอนุญาตให้ originate prefix จริง |
| ROA (Route Origin Authorization) |
Signed object ที่ระบุ prefix + authorized AS |
| Validation States |
Valid (ROA match), Invalid (ROA mismatch), Not Found (no ROA) |
| Action |
Drop Invalid routes, prefer Valid routes |
| ข้อดี |
ป้องกัน BGP hijacking + route origin validation |
Best Practices
| Practice |
รายละเอียด |
| Filter bogons inbound |
Block RFC 1918 + bogon prefixes จากทุก external peers |
| Prefix limit |
Set maximum-prefix บนทุก peering session |
| RPKI validation |
Enable RPKI + drop Invalid origins |
| IRR filtering |
Build prefix filters จาก IRR (RADB, RIPE) databases |
| AS-path filter |
Reject routes กับ private ASNs (64512-65534) ใน path |
| Community-based policy |
ใช้ communities สำหรับ traffic engineering + blackhole |
| Document everything |
Document ทุก filter + policy + peering agreement |
ทิ้งท้าย: BGP Filtering = Internet Stability
BGP Filtering ป้องกัน route leaks + hijacks Prefix lists = match prefix/length, Route maps = complex policy Communities = tag routes สำหรับ policy decisions Filter bogons inbound + RPKI + prefix limits = minimum RPKI + IRR filtering = modern BGP security
อ่านเพิ่มเติมเกี่ยวกับ MPLS L3VPN และ IS-IS Routing Protocol ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com