Sunday, October 22, 2017

Manipulasi BGP Routing Menggunakan Community List di Cisco Router

Untuk melakukan filtering di BGP ada banyak cara bisa menggunakan Prefix-List, AS-Path List dengan kombinasi regular expression, dan Community List. Community list dalam BGP biasanya digunakan untuk mengidentifikasi dan memfilter route bedasarkan community tag mereka, konsepnya sama dengan Route Tag. Hampir sama pula dengan access list, community list memiliki format dan range, ada standard format (1 - 99) dan ada extended format (100 - 199), ada juga bedasarkan name dan ini unlimited. Format konfigurasi paling umum ialah seperti dibawah ini.
  • Standard numbered list:
         ip community-list list-number {permit | deny} community-number
  • Expanded numbered list:
         ip community-list list-number {permit | deny} regular-expression
  • Standard named list:
        
    ip community-list standard list-name {permit | denycommunity-number
  • Expanded named list:
       
    ip community-list expanded list-name {permit | denyregular-expression
Di dalam Cisco Router by default community number value itu 32-bit yaitu 1 - 4294967295, sedangkan format yang paling sering digunakan ialah new format number dengan format aa:nn (the new format), format baru ini adalah format yang paling sering digunakan, namun harus mengenable dulu di global config menggunakan command ip bgp-community new-format

Sekarang mari ke contoh penggunaan beserta contoh konfigurasinya, dalam lab ini topologi yang digunakan ialah topologi sederhana seperti dibawah ini agar mudah dipahami.


Pada skenario ini ceritanya pada kondisi default apabila trafik dari R1 ingin ke segmen yang ada di R2 maka akan melewati 10.10.10.2.














Nah tujuan utama dari lab kali ini ialah memanipulasi trafik dari R1 apabila ingin menuju ke segmen 2.2.2.2/32 di R2 maka best path nya harus melalui 10.10.10.6, sedangkan yang lainnya menuju ke 22.22.22.22/32 tetap melewati 10.10.10.2. Manipulasi yang dilakukan ialah menggunakan community-list, dibawah ini ialah langkah-langkahnya.

1) Langkah Pertama Mentagging Segmen 2.2.2.2/32 dengan Community List 2:200 di R2
R2(config)# ip bgp-community new-format
R2(config)# access-list 1 permit 2.2.2.2
R2(config)# route-map R1peer permit 10
R2(config-route-map)# match ip address 1
R2(config-route-map)# set community 2:200
R2(config-route-map)# exit 
R2(config)# route-map R1peer permit 20
R2(config-route-map)# exit 
R2(config)# router bgp 2
R2(config-router)# neighbor 10.10.10.1 send-community
R2(config-router)# neighbor 10.10.10.5 send-community
R2(config-router)# neighbor 10.10.10.5 route-map R1peer out

Notes
  • Command send-community dibutuhkan agar R1 dapat menerima informasi community yang telah dibuat di R2.
  • Command neighbor 10.10.10.5 route-map R1peer out dibuat agar R2 mengirim informasi community tag 2:200 melalui link point-to-point 10.10.10.4/30.

2) Verifikasi Apakah Segmen 2.2.2.2/32 di R1 Sudah ada Tag Community nya?


















Perhatikan dari informasi diatas bahwa kita menerima informasi bahwa network segmen 2.2.2.2/32 dari R2 dari 10.10.10.6 merupakan community 2:200. Secara logik maka sekarang apabila digambarkan jadi seperti dibawah ini.









3) Membuat Policy di R1 Agar Menuju 2.2.2.2/32 Melalui 10.10.10.6
R1(config)# ip bgp-community new-format
R1(config)# ip community-list 1 permit 2:200
R1(config)# route-map R2peer permit 10
R1(config-route-map)# match community 1

R1(config-route-map)# set local-preference 120
R1(config-route-map)# exit
R1(config)# route-map R2peer permit 20
R1(config-route-map)# exit
R1(config)# router bgp 1
R1(config-router)# neighbor 10.10.10.6 route-map R2peer in

Notes
  • Dalam Route-Map R2peer dibutuhkan command set local-preference 120, agar BGP atribut dapat berubah dari defaultnya 100 menjadi 120, sehingga ketika dipasang di BGP nya maka jalur itu yang akan dipilih karna value local preferencenya lebih tinggi.
  • Route-Map R2peer dipasang di neighbor yang 10.10.10.6.

4) Verifikasi Apakah Menuju Segmen 2.2.2.2/32 di R1 Sudah Melalui 10.10.10.6?
































Apabila kita lihat hasil verifikasi diatas menggunakan command show ip route dan show ip bgp x.x.x.x maka sudah terlihat bahwa apabila R1 ingin menuju ke segmen 2.2.2.2/32 di R2 maka akan melalui 10.10.10.6, sedangkan apabila ingin menuju 22.22.22.22/32 di R2 tetap melalui 10.10.10.2.

Berhasil kan? Perlu di notes sih penggunaan community di dunia real ini sangat sering terutama ketika network sudah growing begitu besar, seperti manipulasi routing ke cabang, atau manipulasi routing antara data center dan masih banyak lagi contoh use cases lainnya.

Untuk full konfigurasi dari simulasi diatas seperti dibawah ini yah.

R1
R1#show run
Building configuration...

Current configuration : 1531 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
archive
 log config
  hidekeys
!
!
!
!
ip tcp synwait-time 5
!
!
!
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 ip address 10.10.10.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.10.10.5 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet2/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router bgp 1
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 neighbor 10.10.10.2 remote-as 2
 neighbor 10.10.10.6 remote-as 2
 neighbor 10.10.10.6 route-map R2peer in
 no auto-summary
!
ip forward-protocol nd
!
ip bgp-community new-format
ip community-list 1 permit 2:200
!
no ip http server
no ip http secure-server
!
no cdp log mismatch duplex
!
!
!
route-map R2peer permit 10
 match community 1
 set local-preference 120
!
route-map R2peer permit 20
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
!
end

R2
R2#show run
Building configuration...

Current configuration : 1700 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
archive
 log config
  hidekeys
!
!
!
!
ip tcp synwait-time 5
!
!
!
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Loopback1
 ip address 22.22.22.22 255.255.255.255
!
interface FastEthernet0/0
 ip address 10.10.10.2 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.10.10.6 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet2/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router bgp 2
 no synchronization
 bgp log-neighbor-changes
 network 2.2.2.2 mask 255.255.255.255
 network 22.22.22.22 mask 255.255.255.255
 neighbor 10.10.10.1 remote-as 1
 neighbor 10.10.10.1 send-community
 neighbor 10.10.10.5 remote-as 1
 neighbor 10.10.10.5 send-community
 neighbor 10.10.10.5 route-map R1peer out
 no auto-summary
!
ip forward-protocol nd
!
ip bgp-community new-format
!
no ip http server
no ip http secure-server
!
access-list 1 permit 2.2.2.2
no cdp log mismatch duplex
!
!
!
route-map R1peer permit 10
 match ip address 1
 set community 2:200
!
route-map R1peer permit 20
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
!

end


Semoga bermanfaat...

No comments:

Post a Comment