ยินดีต้อนรับสู่ show running-config ครับ

บล็อก show running-config นี้สร้างไว้เพื่อเป็นแหล่งรวบรวมเทคนิคการตั้งค่าอุปกรณ์เครือข่าย Cisco ไม่ว่าจะเป็น Cisco IOS Router, Cisco Catalyst Swtich, Cisco ASA Firewall, Cisco Mars เป็นต้น รวมทั้งอาจจะมีเทคนิคการตั้งค่าอุปกรณ์ในยี่ห้ออื่น ๆ บ้างเล็กน้อยครับ

ซึ่งบทความในบล็อกนี้ก็จะรวบรวมมาจากประสบการณ์ส่วนตัวของกระผมเองครับ (หากมีข้อผิดพลาดก็ขออภัยไว้ล่วงหน้าเลยละกันนะครับ) และก็อยากใช้พื้นที่แห่งนี้เป็นแหล่งในการแลกเปลี่ยนความรู้ รวมไปถึงวิธีการหรือเทคนิคการตั้งค่าอุปกรณ์เครือข่าย กับทุก ๆ คนครับ

Saturday, March 19, 2016

การใช้งานคำสั่ง bgp redistribute-internal


          โดยปกติในการ redistribution ระหว่าง BGP กับ IGP จะทำการ redistribution เฉพาะ eBGP ไปยัง IGP เท่านั้น ซึ่งโดย default จะไม่ทำการ redistribution prefix ที่เรียนรู้มาจาก iBGP ไปยังโปรโตคอล IGP (เช่น OSPF, IS-IS)

ตัวอย่างจากภาพด้านล่าง


  • ระหว่างเราเตอร์ R1 และ R2 ใช้งานเฉพาะ iBGP ในการแลกเปลี่ยนข้อมูลเส้นทาง
  • ระหว่างเราเตอร์ R2 และ R3 ใช้งานเฉพาะ IGP (OSPF) ในการแลกเปลี่ยนข้อมูลเส้นทาง
R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
 ip address 10.1.2.1 255.255.255.0
!
router bgp 100
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 neighbor 10.1.2.2 remote-as 100
!
R2
!
interface Ethernet0/0
 ip address 10.1.2.2 255.255.255.0
!
interface Ethernet0/1
 ip address 10.2.3.1 255.255.255.0
!
router ospf 1
 redistribute bgp 100 subnets
 network 10.2.3.1 0.0.0.0 area 0
!
router bgp 100
 bgp log-neighbor-changes
 neighbor 10.1.2.1 remote-as 100
!
R3
!
interface Ethernet0/0
 ip address 10.2.3.2 255.255.255.0
!
router ospf 1
 network 10.2.3.2 0.0.0.0 area 0
!

ตรวจสอบการทำงาน

R1
R1#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       0.0.0.0                  0         32768 i

R1#show ip route
Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets
C        1.1.1.1 is directly connected, Loopback0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.1.2.0/24 is directly connected, Ethernet0/0
L        10.1.2.1/32 is directly connected, Ethernet0/0
R2
R2#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 1.1.1.1/32       10.1.2.1                 0    100      0 i

R2#show ip route
Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets
B        1.1.1.1 [200/0] via 10.1.2.1, 00:07:09
      10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C        10.1.2.0/24 is directly connected, Ethernet0/0
L        10.1.2.2/32 is directly connected, Ethernet0/0
C        10.2.3.0/24 is directly connected, Ethernet0/1
L        10.2.3.1/32 is directly connected, Ethernet0/1
R3
R3#show ip route
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.2.3.0/24 is directly connected, Ethernet0/0
L        10.2.3.2/32 is directly connected, Ethernet0/0

          Prefix ที่เราเตอร์ R1 ประกาศไปให้กับเราเตอร์ R2 แบบ iBGP (จากตัวอย่างคือ 1.1.1.1/32) เราเตอร์ R2 จะได้รับ prefix ดังกล่าว โดยจะนำไปใช้งานใน routing table แต่ prefix นี้จะไม่ถูก redistribute ไปยัง OSPF เพื่อส่งต่อไปให้กับเราเตอร์ R3 ทำให้เราเตอร์ R3 ไม่มีข้อมูลเส้นทางไปยัง 1.1.1.1/32

          ในกรณีที่ต้องการให้ทำการ redistribution iBGP ไปยัง IGP จะต้องใช้คำสั่ง "bgp redistribute-internal" ภายใต้ router configuration mode ด้วย แต่ในการใช้งานคำสั่งนี้ควรจะใช้อย่างระมัดระวัง เนื่องจากอาจจะทำให้เกิด routing loop ขึ้นในระบบเครือข่ายได้

R2
R2(config)#router bgp 100
R2(config-router)#bgp redistribute-internal

          คำสั่ง "bgp redistribute-internal" จะใช้งานในบางกรณีเท่านั้น เนื่องจากโดยปกติแล้ว เราเตอร์ที่ใช้งาน iBGP ระหว่างกัน ก็จะมีการใช้งาน IGP ร่วมกันด้วยอยู่แล้ว ทำให้ไม่จำเป็นที่จะต้องใช้คำสั่ง "bgp redistribute-internal" ดังกล่าว ก็สามารถเรียนรู้ prefix ได้จาก IGP โดยตรงอยู่แล้ว ดังนั้น คำสั่งนี้จึงควรที่จะใช้งานในบางกรณีเท่านั้น คือมีการใช้งาน iBGP บนเราเตอร์ที่ไม่ได้ใช้งาน IGP ร่วมกัน และต้องการ redistribute prefix ที่เรียนรู้มาจาก iBGP เข้าไปยัง IGP เพื่อส่งข้อมูลเส้นทางไปยังส่วนอื่น ๆ ของระบบเครือข่ายต่อไป

R3
R3#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets
O E2     1.1.1.1 [110/1] via 10.2.3.1, 00:00:48, Ethernet0/0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.2.3.0/24 is directly connected, Ethernet0/0
L        10.2.3.2/32 is directly connected, Ethernet0/0

No comments:

Post a Comment