Border Gateway Protocol (BGP)

PlAwAnSaI

Administrator
  • Router ที่ Support น่าจะเกือบทุกตัว แต่ถ้ารับ Route Internet คิดว่าน่าจะ 3800 อย่างต่ำ แล้วก็ขึ้นอยู่กับ Memory ด้วย
  • BGP ย่อมาจาก Border Gateway Protocol เป็น Protocol เลือกเส้นทางประเภท Exterior Gateway Protocol (EGP)
  • จะมาพูดถึงกันแบบละเอียด ถ้าคนพิมพ์มีเวลาว่างพอ 555+ สงสัยอะไร หรือผิดพลาดประการใด ก็แจ้งมาได้เลยคับ
  • มันเป็น Interdomain Routing, Domain ก็คือ AS เพราะฉะนั้นหลักๆ มันก็จะเอาไว้ใช้เพื่อเชื่อมต่อกับ Router และเครือข่ายที่อยู่ต่าง AS (1 AS ก็คือ 1 ISP น่ะ แหละ)
  • โดยหลักการแล้ว AS Number เป็นเลขหมายในทางตรรกะที่กำหนดให้กับ Router ทุกตัวที่ทำงานอยู่ภายใต้ระบบการจัดการเดียวกัน โดย Router เหล่านี้จะมีการแบ่งปัน (Share) ข่าวสารเกี่ยวกับตารางเลือกเส้นทาง และมีการ Update ภายใต้สภาวการณ์ปกติ โดยเฉพาะเมื่อมีการเปลี่ยนแปลงใดๆ เกิดขึ้น มาตรฐานการกำหนดเลขหมาย AS อยู่ภายใต้การดำเนินงานของ Internet Assigned Numbers Authority (IANA) ที่เป็นผู้กำหนดเลขหมาย AS บน Internet โดยเลขหมาย AS นี้สามารถมีได้ตั้งแต่ 1 - 65,535 แบ่งเป็น Public AS Number และ Private AS Number โดยมีเลข 64,512 ไปจนถึง 65,535 ถูกสำรองไว้ให้กับเครือข่ายส่วนตัวที่ไม่ได้ทำงานบน Internet (Private AS Number) เช่นเดียวกับ Private IP Address โดยปัจจุบันนี้ เพิ่มเป็น 4 Byte แล้ว
  • ใช้โดย ISP เป็น Routing หลักของโลกใบนี้
  • เป็น Protocol เลือกเส้นทางบน Internet ซึ่งปัจจุบันนี้มี Route ถึง 700,000 กว่า Route แล้ว
    www.cidr-report.org/as2.0
  • ใช้งาน Protocol TCP จึงทำให้มีความปลอดภัย ต้องทำ 3 Way Handshake และใช้ Sliding Window จึงส่งข้อมูลได้เป็นก้อนๆ ไม่เหมือนกับ OSPF และ EIGRP ซึ่งใช้ Protocol UDP ส่งได้ทีละ 1 Packet
  • ไม่สนใจ Bandwidth ในการคำนวณหาเส้นทาง จะดูจาก Policy ที่กำหนดไว้เท่านั้น
  • เป็น Advanced Distance Vector เพราะพัฒนามาจาก Distance Vector
  • จะ Update เมื่อมีการเปลี่ยนแปลงเครือข่ายเกิดขึ้นเท่านั้น ซึ่งเป็นข้อเสียของ TCP จึงต้องมี Hello Message ขึ้นมา ใน BGP จะเรียกว่า Keepalive เข้ามาช่วยตรวจสอบ การมีชีวิตอยู่ของเพื่อนบ้าน สามารถคุยกับอุปกรณ์ยี่ห้ออื่นได้เพราะเป็นมาตรฐานของ RFC
  • Metrics เรียกว่า Attributes มีเยอะมาก
  • มันจะเลือกเองว่าตัวไหนเป็น Server หรือ Client ในการส่ง Update
  • เวลาเปลี่ยน Configure หรือ Policy จะใช้เวลา Update นานเป็นนาที จึงจะเห็นผล ต้อง Clear Routing จึงจะเห็นผลเลย
  • เหมาะกับเครือข่ายหรือโครงข่ายที่มีความสลับซับซ้อน ให้ประสิทธิภาพการทำงานมากที่สุดตัวหนึ่ง
  • Router ใน AS หนึ่งๆ จะมีการเชื่อมต่อกับ AS อื่นๆ อีกหลายๆ AS ตัว Router ใน AS นั้นๆ จะทำหน้าที่เป็นทางผ่านของ AS อื่นๆ ได้ เช่น AS200 เป็นทางผ่านของ AS100 กับ AS300 โดยจะแยกออกเป็น 2 Protocol ย่อยๆ
    • IBGP (Internal BGP) ใช้ส่งระหว่าง Router ที่อยู่ภายใต้ AS ที่มีเลขหมายเดียวกัน
    • EBGP (External BGP) ใช้ส่งระหว่าง Router ที่อยู่ภายใต้ AS ที่มีเลขหมายต่างกัน
  • Triggered Updates ของ IBGP จะส่งทุกๆ 5 วินาที, EBGP 30 วินาที
  • ข้อเสียของมันก็มีคือกิน Resource (CPU, Memory) เพราะต้องสร้าง TCP Session เยอะ และ Update ช้านั่นเอง
  • ลักษณะของเครือข่ายจะมี 2 แบบคือ แบบ Single-Homed และ Multihomed
  • Single-Homed เป็นการต่อไปยัง ISP รายเดียว ลูกค้าก็จะเป็นพวกลูกค้ารายใหญ่ๆ หรือ ISP รายเล็กๆ จะใช้ BGP ก็ต่อเมื่อ มีหลาย Link หรือต้องการตรวจสอบความผิดปกติของฝั่ง ISP โดยต้องใช้ Private AS Number ถ้าไม่ตามเงื่อนไขนี้ใช้ Static Route ก็ได้
  • Multihomed เป็นการต่อไปยัง ISP มากกว่า 1 ราย เช่นในกรณีที่ต้องการทำ Full Backup ใช้ได้แต่ BGP ใช้ Public AS Number และ Public IP Address
  • Router ที่ Run BGP จะเป็นแค่ทางผ่านเท่านั้น จึงไม่สามารถควบคุม Routing ที่เป็น Downstream ได้ เป็นแค่ทางเลือกหนึ่งเท่านั้น
  • ปกติ Protocol เลือกเส้นทางทั่วไปจะใช้วิธีการเลือกเส้นทางที่ดีที่สุดต่างกัน เช่น RIP จะใช้จำนวน Hop เป็นหลัก ขณะที่ IGRP ใช้ Bandwidth เป็นหลัก ส่วน EIGRP ใช้การผสมผสานกันระหว่าง Bandwidth และ Delay เป็นแนวทางในการเลือกเส้นทาง นอกจากนี้ OSPF ใช้ค่า Cost เป็นหลัก แต่ BGP ใช้ Attribute เป็นหลักในการเลือกเส้นทางที่ดีที่สุด การใช้ Attribute ของ BGP ไม่เพียงแต่ต้องการรับข้อมูลข่าวสารเกี่ยวกับเส้นทางเท่านั้น แต่ใช้เพื่อพิสูจน์เส้นทางที่ดีที่สุดที่จะเดินทางไปสู่ปลายทาง

Best Path Selection Algorithm in order:


BGP สามารถรับการประกาศเส้นทางหลายๆ ชุด จากเส้นทางเดียวกัน โดยเส้นทางหลายๆ ชุดนี้มาจากแหล่งต่างๆ กันหลายแห่งได้ แต่จะเลือกเส้นทางใดเส้นทางหนึ่งที่เห็นว่าดีที่สุด เมื่อเส้นทางที่ดีที่สุดถูกเลือกแล้ว จะนำเส้นทางที่ดีที่สุดที่เลือกแล้วนี้ไปไว้ใน Routing Table จากนั้นก็จะเผยแพร่เส้นทางนี้ไปสู่ Router เพื่อนบ้าน มีข้อพิจารณาอยู่ตามลำดับดังนี้

  1. BGP next-hop has to be reachable - consider Only (synchronized) route with no AS loops and a valid Next hop - หากเส้นทางระบุปลายทางที่ไม่สามารถเข้าถึงได้ จะมีการยกเลิกการ Update, and then:
  2. Longest match wins
  3. Prefer the highest Weight (Local to a router). - ค่า Weight มากสุด (Cisco Proprietary ใช้เฉพาะภายใน Router ตัวเดียวเท่านั้น)
    The weight attribute basically a Cisco proprietary technology and considered as the first attribute. The default value of weight is 0 and the range is from 0 to 65535.
    (config-router) # neighbor 50.1.1.1 weight 100
  4. Prefer highest Local preference (Global within AS). - ค่า Local Preference มากสุด (Default เป็น 100)
  5. Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command
  6. Shorter AS-Path length wins
  7. Prefer the path with the lowest Origin type: IGP < EGP < INCOMPLETE
  8. Lowest MED
  9. Prefer eBGP over iBGP
  10. Lowest IGP metric to the BGP next-hop - BGP next-hop ที่มี Cost IGP น้อยสุด
  11. Multipath
  12. Prefer the oldest route (received first) for eBGP paths. - เลือกเส้นทางที่อยู่นานที่สุดสำหรับ eBGP เช่น ในการทำ Dampening
  13. Prefer the path with the lowest neighbor BGP router ID. - เลือกเส้นทางที่มาจาก Router ที่มีค่า BGP Router ID น้อยสุด
  14. Minimum cluster list length in BGP RR environments
  15. Prefer lowest neighbor address
ถ้าเท่ากันทุกข้อจะ Load-balance

Example:

Router R1#show ip bgp vpnv4 rd 1100:1001 10.30.116.0/23

Code:
(65001 64955 65003) 65089, (Received from a RR-client)<br />
172.16.254.226 (metric 20645) from 172.16.224.236 (172.16.224.236)<br />
Origin IGP, metric 0, localpref 100, valid, confed-internal<br />
Extended Community: RT:1100:1001<br />
mpls labels in/out nolabel/362<br />
<br>  (65008 64955 65003) 65089<br />
172.16.254.226 (metric 20645) from 10.131.123.71 (10.131.123.71)<br />
Origin IGP, metric 0, localpref 100, valid, confed-external<br />
Extended Community: RT:1100:1001<br />
mpls labels in/out nolabel/362<br><br>0. The paths should always be valid if see them in the output of "show ip bgp".

Example: Reason that router RT-3 chose router RT-1 as its best path to network 131.25.0.0/16.

BGP_router_ID.jpg

Recall the best path selection algorithm:
1. RT-3 is not an exit point
4. same local preference of 100
5. both routes are from IBGP
6. same
7. both are incomplete (EGP > IGP > Incomplete)
8. both MEDs are 0
9. both are IBGP
11. not used because IBGP is used
12. not used
13. the router-id 162.105.11.1 is lower than 165.105.3.2

Cr: Dr.วิรินทร์ & Cisco
cool.gif
 

PlAwAnSaI

Administrator
  • Attributes แบ่งออกได้เป็น 2 แบบ คือ Well-known และ Optional
    • Well-known

      Attributes ก็ยังแบ่งออกอีก 2 แบบ คือ:
      • Mandatory จะมีอยู่ในทุก Update และ
      • Discretionary จะมีหรือไม่มีก็ได้ แต่ถ้าส่งออกไปแล้วทุกคนจะรู้จัก
    • Mandatory ก็จะประกอบด้วย Origin Attribute เอาไว้ใช้บอกว่า Route นั้นเกิดมาจากอะไร จะอยู่ใน BGP Table โดย:
      • i = IGP ข่าวสารเกี่ยวกับเส้นทางที่จะเข้าถึงเครือข่าย มาจากการใช้คำสั่ง
        (config-router)#network x.x.x.x ประกาศ Route ธรรมดา
      • e = ได้รับการเรียนรู้โดย EGP ปัจจุบันนี้ไม่ค่อยเห็นแล้ว
      • ? = ได้รับการเรียนรู้โดยเหตุผลอื่นๆ เช่น การทำ Redistributed Route เข้ามาข้างใน BGP
  • AS-Path Attribute AS-Path Attribute เป็นรายชื่อของ AS ที่ Route Update ได้วิ่งผ่านและบันทึกไว้ เพื่อให้ทราบว่ามาจากที่ใด และเป็นกลไกสำคัญในการป้องกัน Loop ระหว่าง AS อีกทั้ง Router ยังใช้เพื่อเป็นการกำหนดเส้นทางเชิงนโยบายที่มีเนื้อหาที่กำหนดข้อจำกัดต่างๆ
    • iBGP รับมาต้องส่งออกไปเหมือนเดิมทุกครั้งไม่มีการเปลี่ยนแปลง
    • EBGP จะเพิ่ม AS Number ของตัวเองเข้าไปเวลาส่ง ใน Packet จึงมี AS ทั้งหมดที่ผ่านมาอยู่ด้วย
    และ

    Next-hop Attribute เป็น IP Address ของ Hop ต่อไปที่จะใช้เพื่อเดินทางไปสู่เครือข่ายปลายทาง สำหรับ EBGP จะหมายถึง IP Address ของเพื่อนบ้านที่กำหนดขึ้นโดยคำสั่ง neighbor
  • Discretionary ประกอบด้วย Local Preference และ Atomic Aggregate
  • Optional Attributes จะส่งต่อถ้ารู้จัก ถ้าไม่รู้จักจะมี 2 ทางเลือก คือ Transitive จะส่งโดยการเพิ่ม Partial Bit เข้าไป เช่น Route Summary, Community และ Non-transitive จะไม่ส่ง Attribute นี้เลย
  • Next-Hop Attribute ก็คือ IP Address ที่ Interface ของ Router อีก AS นึงที่ต่ออยู่กับ Router ภายใน AS ของเรา แต่ถ้าต่อผ่าน Shared Media คือ มี IP Address อยู่ใน Subnet เดียวกัน มันจะไม่เปลี่ยน Next-Hop
  • Weight Attribute เป็นมาตรฐานของ Cisco ที่ Router ใช้เป็นการภายใน จะไม่มีการประกาศออกไปที่ Router เพื่อนบ้าน
  • Local Preference Attribute จะบ่งบอกแก่ AS เกี่ยวกับเส้นทางที่ต้องการใช้เป็นทางออกไปจาก AS เพื่อเดินทางไปสู่เครือข่ายปลายทาง ค่า Default ของ Local Preference คือ 100
  • Multi-Exit Discriminator Attribute (MED) ทำหน้าที่ชี้นำเพื่อนบ้านที่อยู่ภายนอก AS เกี่ยวกับเส้นทางที่เหมาะสมที่สุดที่จะเข้ามาภายใน AS ใน AS ต่างกันจะมีการแลกเปลี่ยน Metric กัน ค่า Metric จะถูกนำเข้ามาใน AS แต่จะไม่ถูกส่งออกไป เมื่อใดที่ค่า Metric ถูกนำเข้ามาใน AS จะนำค่านี้ไปทำการตัดสินใจเลือกเส้นทางต่อไป ค่า Default ของ Metric คือ 0 หากไม่กำหนดค่าใดๆ ตัว Router จะทำการเปรียบเทียบค่า Metric ของเส้นทางจากเพื่อนบ้านที่อยู่ใน AS เดียวกันเท่านั้น เพื่อให้ Router สามารถเปรียบเทียบค่า Metric จากเพื่อนบ้านที่อยู่ต่าง AS กัน จะต้องใช้คำสั่ง (config-router)# bgp always-compare-med
  • Community Attribute เป็นวิถีทางที่จะรวมกลุ่มเส้นทางที่เป็นปลายทางเข้าด้วยกันเป็นกลุ่ม มีการใช้ Route Map เพื่อจัดตั้ง มาตรฐานจะมี 4 แบบ ทุกแบบจะกล่าวถึง Router ที่ Run BGP เท่านั้น
    no-export: ไม่ประกาศเส้นทางนี้ไปต่าง AS
    no-advertise: ไม่ประกาศเส้นทางนี้สู่เราท์เตอร์ใดๆ
    local-as: ไม่ประกาศเส้นทางนี้ไปต่าง AS รวมทั้งคนละ Intra-Confederation ด้วย
    internet: ประกาศเส้นทางนี้สู่เราท์เตอร์ใดๆ
  • เครือข่าย Frame Relay จะต้องทำเป็น Full Meshed
  • Neighbors ไม่สามารถค้นหาเองได้ ต้อง Configure เองเท่านั้น ต้องทำทั้ง 2 ฝั่ง

    Router ทั้ง 2 ตัว จะสร้าง TCP Session Port หมายเลข 179 ขึ้นมา เพื่อใช้ในการขนถ่ายข้อมูลข่าวสาร แต่จะใช้งานจริงแค่ Session เดียว IP Address ปลายทางที่เข้ามา จะถูกนำไปตรวจสอบกับ Command neighbor มันจะใช้ TCP เพื่อการสถาปนาการเชื่อมต่อระหว่างกัน โดยการใช้ Open Message ก่อนจะแลกเปลี่ยนข้อมูลข่าวสารระหว่างเราท์เตอร์ BGP ทั้งสอง (Peer Router)
  • เมื่อใช้ command neighbor แล้ว sho ip bgp sum ตรง State จะเป็น Idle
  • ชนิดของข่าวสารที่ใช้ มีอยู่ 4 แบบ
    Open Message - ใช้เพื่อการสถาปนาจัดตั้งการเชื่อมต่อระหว่าง Router BGP ประกอบด้วย BGP version number, AS number บอกว่ามาจาก AS อะไร, Holdtime บอกว่าจะตายเมื่อไหร่, Router-ID และ Option
    Keepalives - เป็นข่าวสารที่ใช้ทักทายเราเตอร์เพื่อนบ้าน โดยการส่งออกมาเป็นห้วงเวลาที่แน่นอนเพื่อการตรวจสอบเส้นทาง หากค่านี้ถูกตั้งเป็น "0" จะหมายถึง Infinity ซึ่งหมายความว่าจะไม่มีการส่ง Keepalive Message เกิดขึ้น โดยปกติจะส่งทุก 60 วินาที
    Update Message - ประกอบด้วยข้อมูลเกี่ยวกับเส้นทาง รวมทั้ง Path Attribute ครอบคลุมไปถึง Route ที่ถูกถอดออกจาก Routing Table หรือไม่มีตัวตนแล้ว จะ Update 1 Path ต่อ 1 Update หากมีหลายๆ Path ก็ต้องมีหลาย Update
    Notification - ใช้เพื่อการแจ้งเตือนความผิดพลาดที่เกิดขึ้น
  • Transit AS เป็นระบบ AS ที่ข้อมูลข่าวสารจะต้องวิ่งผ่าน AS หนึ่งไปยังอีก AS หนึ่ง เช่น AS 30 เป็นทางผ่านของ AS 10 เพื่อเดินทางไปสู่ AS 50 เป็นต้น
  • สามารถใช้ MD5 ในการ authen ระหว่าง peers ได้ โดยทั้งสองฝั่งต้องมี password เหมือนกัน ช่วยในการป้องกัน DoS หรือ man-in-the-middle ได้
  • BGP Route Dampening (ระบบทำโทษ/ดอง) ออกแบบมาจัดการกับ Link ที่ Up/Down บ่อยๆ หลักการทำงานของมันก็คือ มันจะตั้งแต้มเอาไว้ เวลา Flap (Down) 1 ครั้ง มันจะหักแต้มนั้นไป 1000 แต้ม และเก็บเอาไว้ประจำเส้นทางนั้น ถ้าโดนหักแต้มไว้เกินค่าที่ตั้งไว้ ถึง Link ปกติแล้ว มันก็จะไม่ส่ง Update ไปหาเพื่อนบ้านของมันทางนี้อีก จนกว่าจะถึงค่าเวลาที่กำหนดให้กลับมาใช้ใหม่ได้ (reuse limit)
    (config-router)#bgp dampening [half-life reuse suppress max-suppress-time] [route-map map-name]
  • *Jan 3 10:29:18.139: BGP: 3.3.3.3 active open failed - tcb is not available, open active delayed 12288ms (35000ms max, 60% jitter)
    Amsterdam(config-router)#neighbor 3.3.3.3 update-source lo0
  • Understanding BGP Regular Expressions
    gponsolution.com/bgp-regular-expressions-cheat-sheet.html
  • Global BGP Prefix Count
    bgp.he.net/report/netstats
  • โลกจริงของอินเตอร์เนต, Internet Tier hierarchy, Peering, IP Transit, AS number
    www.thainetworker.com/โลกจริงของอินเตอร์เนต
  • Basic BGP Configuration - Part 1
http://www.youtube.com/watch?v=pbudQ-Cybak
  • BGP Route Reflectors and Clusters
    gns3vault.com/BGP/bgp-route-reflectors-and-clusters.html
Configuration Example:

  • R1#
    router bgp 700
    neighbor 10.170.117.229 remote-as 700 -> IBGP

    แค่ 2 บรรทัดนี้ Neighbor ก็ Up แล้ว
    R1# sho ip bgp sum

    Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
    10.170.117.230 4 700 12 13 2 0 0 00:09:24 0
  • ทีนี้ถ้าจะ Test ส่ง Prefix ล่ะทำไง? ก็นี่เลยง่ายๆ
    R1#
    ip route 192.168.0.0 255.255.255.0 Null0
    !
    router bgp 700
    network 192.168.0.0 -> Classful mask 24 อยู่แล้วไม่ต้องใส่อีก

    R2# sho ip rou bgp
    B 192.168.0.0/24 [200/0] via 10.170.117.230, 00:18:19
  • Router Cisco Tune Outbound ง่ายๆ ด้วย Weight
    router bgp 700
    neighbor 10.170.117.229 weight 200
    gns3vault.com/bgp/bgp-attribute-weight
  • Optional:
    router bgp 700
    neighbor 8.8.8.8 password cisco123 -> Authentication Key = cisco123
    neighbor 8.8.8.8 update-source Loopback0 -> Update Source Loopback 0
    neighbor 192.168.1.1 remote-as 100 -> EBGP
Cr: Dr.วิรินทร์ & Cisco
cool.gif
 

PlAwAnSaI

Administrator
จุดประสงค์ของการใช้ BGP

  • BGP ให้ประโยชน์อย่างเห็นได้ชัด โดยเฉพาะการเชื่อมต่อเครือข่ายต่างๆ รวมทั้งลูกค้า และผู้ให้บริการโทรศัพท์ รวมทั้งเครือข่ายอื่นๆ
  • BGP เหมาะอย่างยิ่งสำหรับการเชื่อมต่อเครือข่ายในรูปแบบของ Autonomous ต่างๆ เข้าด้วยกัน
  • BGP เหมาะอย่างยิ่งสำหรับการเชื่อมต่อเครือข่ายในระดับ Enterprise หากองค์กรมีการเชื่อมต่อกับ Internet แบบหลายเชื่อมต่อ เพื่อผลแห่ง Redundancy, BGP ยังสามารถทำ Load Balancing Traffic ได้บนเส้นทางที่เป็น Redundant Link
  • จัดเลือกเส้นทางผ่านทางเครือข่ายไปยัง Autonomous System อื่นๆ ที่เชื่อมต่อกัน
  • มีการเชื่อมต่อระหว่าง Autonomous System มากกว่า 1 เส้น
  • ควบคุมการลำเลียงข้อมูลข่าวสารที่วิ่งไปมาระหว่างระบบ Autonomous System

  • Update-source:
    โดยปกติจะใช้ Loopback 0 ในการ Peer iBGP กัน แต่ BGP จะใช้ IP Interface ที่ส่งออกไปในการ Peer ทำให้ไม่สามารถ Form BGP Neighbor กันได้
  • Next-hop-self:
    Configure บน Router ที่ต่อ EBGP External AS เพื่อให้ Router iBGP ภายใน สามารถออกไปนอก AS ได้ หากไม่ใช้ Router iBGP ภายใน จะเห็น Next Hop เป็น IP WAN ของ eBGP
    neighbor next-hop-self

  • Network mask :
    Configure บน Router ที่ต่อ EBGP External AS เพื่อประกาศ WAN IP ทำให้ Router iBGP ภายใน สามารถออกไปนอก AS ได้ หากไม่ใช้ Router iBGP ภายใน จะใช้ Source เป็น WAN IP แต่ Best Practice จะทำการ Summary (WAN + Loopback) ออกไปหา AS ภายนอก
    network 192.168.23.0 mask 255.255.255.0
Troubleshooting:
  • ping source
  • sho tcp brief | inc
  • For BGP outgoing traffic local preference attribute is commonly used
  • BGP inbound traffic engineering can be achieved in multiple ways:
    • Weigth but local to the router and many implementations may not support
    • MED (BGP external metric attribute)
    • AS-path prepending
    • BGP community attribute
There are 3 basic flavors of BGP Internet Edge Design and Multihoming:

  1. Primary/Backup: Common reason for design model is one link is more expensive than the other
    • Inbound: from Internet to the customer
      • Same AS:
        • setting higher MED on backup link(s)
        • AS path prepend on backup link(s)
      • Different ASes:
        • having the Provider set low local preference on backup link(s)
        • evilrouters.net/2009/03/18/using-bgp-communities-to-influence-routing
    • Outbound:
      • learning a default route for the router resources
      • setting lower local preference on the backup link
  2. Load Sharing across all links: Common use case where larger links are cost prohibitive such as for small companies or locations where circuit cost is high
    • Inbound:
      • dividing IP subnets of the company and making particular more specific route announcement across different links
      • Aggregate announcement for case one of the links fail, remaining link can receive traffic
    • Outbound:
      • equal cost static default routes
      • if necessary, more specific prefixes were created
  3. Best path: full Internet routing table is received from all available uplinks to provides ability to send the traffic to the most optimal exit point or closest exit point
When there is congestion on the link(s):
  • Inbound: advertising some destinations as more preferred to the backup/underutilized link(s)
    • higher local-preference or
    • shorter AS-path (AS-path prepending) or
    • lower MED value, don't use it if have connection to more than 1 service provider because the service providers won't send the MED to each other
    • etc
  • Outbound:
    • incresing the IGP distance to the over utilized links for some sources
    • also depreferencing some inbound BGP paths associated with the over utilized links
BGP as-override vs allow-as-in:These 2 functions are pretty similar, just with subtle differences. They can be used in an environment where a customer is using 1 AS number for many sites that are connected to an ISP.
g4yG6d.jpg


AS 100 connects to the ISP at 2 locations. So when R4 receives the prefix 99.99.99.99/32, he will see that AS path is via 200, 100. Because of the loop prevention mechanism, R4 will have to reject this prefix because it can see its own AS in the AS_PATH attribute.

R4# sho ip bgp | beg Network

The debug below shows why he's not accepting these prefixes:

*Mar 1 02:28:03.559: BGP(0): 20.20.20.20 rcv UPDATE about 99.99.99.99/32 -- DENIED due to: AS-PATH contains our own AS;

  1. To fix this is to use the allow-as-in command. This allow R4 to override the loop prevention mechanism by allowing an instance of AS 100 to be in the AS_PATH.
    CE(config-router)#neighbor allowas-in 1 : Number of occurences of AS number
    It keeps all the AS_PATH information and simply just allows 1 occurance of 100 to be in the AS_PATH; thus overriding the loop prevention mechanism.
  2. getting PE (R2&R3) to just strip AS 100 from the BGP UPDATE before sending it to the CE routers.
    PE(config)#router bgp 1
    address-family ipv4 unicast vrf google
    neighbor as-override
    It actually reset the peer, so there's no need to clear any neighbors. The AS_PATH has been overridden by the PE routers to their AS number instead.
This is the key difference between the 2 commands:
  • Allow-as-in allowed the loop prevention to be ignored for the configured amount of instances
  • The as-override caused the PE routers to modify the AS_PATH
  • www.inetdaemon.com/tutorials/internet/ip/routing/bgp/operation/messages/update/nlri.shtml
bgpupdateformat.png

Route Refresh vs Soft Reconfiguration:When adjusting inbound policies with BGP, must request peer to re-sent the update. BGP UPDATES are incremental, meaning after the initial exchange of complete routing information, it only receive changes. So need a way of telling peer to send a BGP UPDATE message with all the NLRI so that can re-run everything through the new filter. There are various ways of doing this, either:
  • A hard reset - dropping/re-establishing TCP sessions to peer, forcing all NLRI to be sent again
  • A soft reset - uses the route-refresh capability to request all NLRI be sent again
  • Or a soft-reconfiguration - storing all unedited, unfiltered NLRI sent from neighbor, in a separate table so that can run it through new filter locally
What is the Route-Refresh Capability?After establishing a TCP session to a BGP peer, the BGP OPEN message is sent. The OPEN message advertises the following information about itself:
  • BGP Version (uaually version 4)
  • BGP AS Number
  • Hold Time
  • BGP Identifier (BGP router-id)
  • Optional Parameters (includes the router's BGP capabilities, such as; authentication, multi protocol support, & route-refresh)
Cr: ccieblog
cool.gif
 

PlAwAnSaI

Administrator
As long as the route refresh capability is supported, able to use the feature. If want to check whether neighbor supports it, can use the following command:R1#sho ip bgp neighbors 192.168.0.2 | sec Neighbor capabilities
Neighbor capabilities:
Route refresh: advertised and received(old & new)
Address family IPv4 Unicast: advertised and receivedIf it does support it, can use the following command to request a route-refresh:R1#clear ip bgp 192.168.0.2 inCan verify that only requested a route refresh by enabling a couple of debug commands:R1#debug ip bgp in
R1#debug ip bgp updates
R1#clear ip bgp 192.168.0.2 in
*Mar 1 00:04:32.031: BGP: 192.168.0.2 sending REFRESH_REQ(5) for afi/safi: 1/1
*Mar 1 00:04:32.031: BGP: 192.168.0.2 send message type 5, length (incl. header) 23The first debug message verifies that only requested a route refresh (i.e. didn't reset the BGP session)

  • www.slideshare.net/vamsidharnaidu/bgp-1
What is soft-reconfiguration inbound?

This feature can be used if route refresh capability is not supported. Because now unable to send a route-refresh request to neighbor, actually have to store an unedited, unfiltered copy all the BGP routes delivered in the BGP update from peer. Then can adjust filters, and run the unedited copy of the NLRI through new filter locally

The process how BGP routes are propagated into the BGP table, and out to a BGP speaker:

Adj-RIBs-In --> Loc-RIB --> Adj-RIBs-Out

The Adj-RIBs-In stores UPDATE messages from other BGP speakers. These are un-edited routes received from neighbor. Next, inbound policy is applied, and routes that pass through the policy & have a valid/resolvable next hop, are put into the Loc-RIB. The rest of the routes in the Adj-RIBs-In are discarded

The Adj-RIBs-Out stores routing information that the BGP speaker will advertise to peers (i.e. routes that have passed through outbound policies & will be sent in the BGP UPDATE messages to other peers)

Soft reconfiguration allows to store a copy of the Adj-RIB-In. Can configure it by using the commands below:

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.0.2 soft-reconfiguration inbound
R1(config-router)#end

The #clear ip bgp soft in : allows the routes now stored in the Adj-RIB-In to be run through new filters and into the Loc-RIB again

Cr: ccieblog

  • orhanergun.net/2016/09/bgp-peering-private-public-bilateral-multilateral-peering
  • www.rogerperkin.co.uk/routing-protocols/bgp/bgp-confederation-vs-route-reflector
  • brbccie.blogspot.com/2012/11/ibgp-route-reflector-loop-prevention.html
  • orhanergun.net/2017/08/bgp-route-reflector-in-plain-english
Multipath Theory:
ccdewiki.wordpress.com/2013/06/05/bgp-route-reflector
  • orhanergun.net/2017/08/unique-rd-per-pe-per-vrf-in-mpls
orhanergun.net/wp-content/uploads/2016/08/BGP-Add-path-vs-Shadow-RR-vs-Shadow-Session-vs-Unique-RD.pdf

แนะนำ Protocol เลือกเส้นทางที่ใช้งานบน Internet เพื่อเชื่อมต่อกับ Router และเครือข่ายต่าง Domain ซึ่งใช้โดย ISP เป็น Protocol ที่เหมาะสำหรับเครือข่ายหรือโครงข่ายที่มีความสลับซับซ้อน และยังให้ประสิทธิภาพในการทำงานมากที่สุดตัวหนึ่ง

BGP คืออะไร?:

BGP (Border Gateway Protocol) เป็น Protocol เลือกเส้นทางประเภท Exterior Gateway Routing ที่ใช้เพื่อการเชื่อมต่อ Router และเครือข่ายที่อยู่ต่าง Domain กันบน Internet

BGP ใช้ Protocol TCP Port หมายเลข 179 เพื่อใช้ในการขนถ่ายข้อมูลข่าวสาร โดยมีการใช้ TCP เพื่อการสถาปนาการเชื่อมต่อก่อนจะแลกเปลี่ยนข้อมูลข่าวสารระหว่าง Router BGP ทั้งสอง (Peer Router) จากนั้นก็จะทำการแลกเปลี่ยนข้อมูลข่าวสาร รวมทั้งการเปิดสัมพันธไมตรีก่อนที่จะแลกเปลี่ยนข่าวสารระหว่างกันต่อไป ข้อมูลข่าวสารที่ Router ทั้งสองใช้เพื่อการแลกเปลี่ยนกัน รวมไปถึงข่าวสารที่แสดงถึงความสามารถในการเข้าถึงกันได้ โดยข่าวสารนี้เป็นในรูปแบบของเลขหมาย AS ของแต่ละฝ่าย ซึ่งต่างฝ่ายถือเป็นเส้นทางในการเข้าหากัน ข้อมูลนี้จะช่วยให้ Router สามารถสร้างผังของเส้นทางที่ปราศจาก Loop ในการเข้าหากัน อีกทั้ง Router ยังใช้เพื่อเป็นการกำหนดเส้นทางเชิงนโยบายที่มีเนื้อหาที่กำหนดข้อจำกัดต่างๆ

BGP for Intermediate:

  • www.youtube.com/watch?v=Mp4t3YmV9_U
  • BGP is an exterior gateway protocol (EGP), used to perform interdomain routing in TCP/IP networks.
  • A BGP router needs to establish a connection (on TCP port 179) to each of it's BGP peers before BGP updates can be exchanged.
  • The BGP session between two BGP peers is said to be an external BGP (eBGP) session if the BGP peers are in different autonomous systems (AS).
  • A BGP session between two BGP peers is said to be an internal BGP (iBGP) session if the BGP peers are in the same autonomous systems.
  • By default, the peer relationship is established using the IP address of the interface closest to the peer router. However, using the neighbor x.x.x.x update-source Gix/x (registered customers only) command, any operational interface, including the loopback interface, can be specified to be used for establishing TCP connections.
  • This method of peering using a loopback interface is useful since it will not bring down the BGP session when there are multiple paths between the BGP peers, which would otherwise result in tearing down the BGP session if the physical interface used for establishing the session goes down.
  • In addition to that, it also allows the routers running BGP with multiple links between them to load balance over the available paths.
  • The BGP Multipath Load Sharing for eBGP and iBGP feature allows you to configure multipath load balancing with both external BGP (eBGP) and internal BGP (iBGP) paths in Border Gateway Protocol (BGP) networks that are configured to use Multiprotocol Label Switching (MPLS) Virtual Private Networks (VPNs).
  • This feature provides improved load balancing deployment and service offering capabilities and is useful for multi-homed autonomous systems and Provider Edge (PE) routers that import both eBGP and iBGP paths from multihomed and stub networks.
  • www.youtube.com/watch?v=_F6lCwaA7ts
  • Administrative Distance:
    • iBGP - 200
    • eBGP - 20
  • TTL:
    • iBGP - 255
    • eBGP - 1
  • Keepalive - 60 Sec.
Lab:

  • IBGP - Internal BGP:
    R1#
    router bgp 1234
    neighbor 2.2.2.2 remote-as 1234 -> IGP Loopback
    neighbor 2.2.2.2 update-source loopback 0
    network 11.11.11.0 mask 255.255.255.0 -> Mask need to match with the routing table
    !
    sho ip bgp sum
    R2# sho ip bgp
    R2# ping 11.11.11.11
    sho ip route bgp
    !
    IBGP assumes a full mesh by default, so it does not pass on routes learned FROM an IBGP peer TO another IBGP peer.
    Use loopback interface can solve SPOF (Single Point of Failure) that whenever a single link goes down, the BGP neighbor relationship will not reset itself.
    www.youtube.com/watch?v=q7Lzjqt6GLY
  • EBGP - External BGP:
    router bgp 1
    neighbor 192.168.12.2 remote-as 2
    neighbor 2.2.2.2 remote-as 2
    neighbor 2.2.2.2 update-source loopback 0
    neighbor 2.2.2.2 ebgp-multihop 2 -> Have to use if not using the physical interface
    !
    Unless advertise WAN Address, have to use source loopback when ping test.
    www.youtube.com/watch?v=D0o-cdhiwjs
cool.gif
 

PlAwAnSaI

Administrator
  • BGP TTL Security:
    router bgp 1
    neighbor 192.168.12.2 ttl-security hops 1
    !
    sho ip bgp nei 192.168.12.2
    !
    Hackers are unable to spoof the BGP peering in any way.
    www.youtube.com/watch?v=YiuzLFEQZY4
  • BGP Transit AS:
    !
    Non-transit AS have to advertise the WAN network connected with the transit AS to the BGP.
    www.youtube.com/watch?v=kSsEDpd40uI
  • BGP Traffic Engineering Unsuppress-Map:
    bgpteunsuppressmap.png
    • AS 3 sends traffic to network 172.16.0.0/24 through router Banshee.
    Behemoth#
    ip prefix-list NOTTHISONE deny 172.16.0.0/22
    ip prefix-list NOTTHISONE permit 0.0.0.0/0 le 32
    !
    access-list 1 permit 172.16.0.0 0.0.0.255
    !
    route-map 172-16-0 permit 10
    match ip address 1
    !
    router bgp 2
    aggregate-address 172.16.0.0 255.255.252.0 summary-only -> Not advertise any specific prefix
    neighbor 192.168.12.1 prefix-list NOTTHISONE out
    neighbor 192.168.23.3 unsuppress-map 172-16-0
    !
    RIB (Routing Information Base) is global routing table (show ip route). If see a RIB-failure it means BGP cannot install this network in the routing table. Can use the show ip bgp rib-failure command to check what is going wrong.
    This might sound 'bad' but it doesn't have to be. If learn a network through OSPF and BGP it will show up as 'RIB-failure' because the administrative distance of OSPF is lower (better) than BGP.
    www.youtube.com/watch?v=T9A_tP2vlVg
  • BGP Timers:
    router bgp 1
    bgp scan-time 30 -> Background scanner interval
    neighbor 192.168.12.2 advertisement-interval 0 -> Don't wait till the next BGP advertisement-interval but send updates immediately
    timers bgp 5 15 -> keepalive: 5, hold time: 15; A hold time of less than 20 seconds increases the chances of peer flapping
    !
    show ip bgp neighbors 192.168.12.2
    !
    Default hold time is 180, keepalive interval is 60 seconds.
    www.youtube.com/watch?v=TTBqpG900YA
  • BGP Next-Hop Self Manual:
    route-map NEXTHOPSELF permit 10
    set ip next-hop 1.1.1.1 -> ASBR's Loopback
    !
    router bgp 100
    neighbor 1.1.1.1 route-map NEXTHOPSELF in
    !
    clear ip bgp *
    www.youtube.com/watch?v=uviYdF1Z3P0
  • BGP Next hop self:
    ASBR#
    router bgp 100
    neighbor 2.2.2.2 next-hop-self -> iBGP peer
    !
    Two ways to solve:
    1. Advertise WAN eBGP to iBGP
    2. Next hop self command
    www.youtube.com/watch?v=kjQ6cUcyVfI
  • Advertising a Default Route:
    ip route 0.0.0.0 0.0.0.0 null 0 254
    1. router bgp 1
      network 0.0.0.0 mask 0.0.0.0
      !
    2. router bgp 1
      default-information originate
      redistribute static
      !
    www.youtube.com/watch?v=j7Qj4feURQc
cool.gif
 

PlAwAnSaI

Administrator
ทำความเข้าใจเกี่ยวกับ AS Path และ AS Path Prepending:

AS Path คืออะไร?

BGP AS Path เป็น Well-known Mandatory Attribute จะมีอยู่ทุก Prefix ที่แลกเปลี่ยนกันระหว่าง BGP Neighbor เมื่อ BGP Router ส่ง Update ไป Neighbor ที่อยู่ต่าง Autonomous System (eBGP Neighbor) มันจะเพิ่มหมายเลข AS ของตัวเองไปที่ด้านหน้า (ด้านซ้าย) ของ AS Path ดังนั้น AS Path จะมี List ของ AS ทั้งหมดที่ผ่านมา ไปจนถึงต้นทางที่ประกาศ Prefix นั้นมา คล้ายๆ กับ Traceroute

จุดประสงค์ของ AS Path คือเอาไว้ป้องกัน Loop, BGP จะทำงานคล้ายกับ RIP ที่เป็น Distance Vector Routing Protocol ซึ่งจะส่ง Routing Table ของตัวเองไปบอก Neighbor, ส่วน Neighbor ก็จะเชื่อมันถ้า Route ที่บอกมาดีกว่าที่ Neighbor มีอยู่

ปัญหาของ Distance Vector Protocol คือ Count to Infinity สมมติว่า Router A และ C เป็นเพื่อนบ้านของ Router B

192.0.2.0/24 - Router A -- Router B -- Router C

Router A บอก B ว่า Prefix 192.0.2.0/24 มาทาง A นะ, B ก็จะเชื่อว่าไปทาง A Hop เดียวนะ แล้วก็ไปบอก C ว่ามาทาง B นะ 2 Hop, เวลา A Down Prefix ก็จะหายไปจาก B แต่ C ยังบอกเพื่อนบ้านมันอยู่ว่าไปหา B สิ 2 Hop, B ก็เป็นเพื่อนบ้านกับ C แถมใน Routing Table ไป A ก็ไม่มีแล้ว ก็เลยเชื่อ B โดยการบวกเพิ่มไปอีก Hop นึง เป็น 3 ทีนี้ C เห็น Update มาจาก B ก็เปลี่ยนเพิ่มเป็น 4 Hop, B ก็ Update มาจาก C อีก เพิ่มเป็น 5 Hop เพื่อไม่ให้ Hop เพิ่มขึ้นเรื่อยๆ ไม่สิ่นสุด RIP จึงออกกฎมาว่าให้สูงสุดได้แค่ 16 Hop

แล้ว BGP ล่ะ? กลับมาที่ประโยคเดิม เวลา A Down Prefix ก็จะหายไปจาก B แต่ C ยังบอกเพื่อนบ้านมันอยู่ว่าไปหา B

สิ 2 Hop, B ก็เป็นเพื่อนบ้านกับ C แถมใน Routing Table ไป A ก็ไม่มีแล้ว แต่มี AS Path ติดมาด้วย C B A อ่าว B เห็นว่าก็กลับมาหาเราอีกนี่นา ทำหูทวนลมซะเลย เลยไม่มีปัญหาแบบ RIP เกิดขึ้น เรียกว่า Path Hunting

Cr: Noction
cool.gif
 
Top