4 Aralık 2016 Pazar

BGP PART 1


Private ASN are 64512 - 65534
Public ASN are 1 - 64511

private as ler aynı private ip ler gibi isp'de anons edilmemelidir.

BGP de KULLANDIGIN SUBNETI TAM OLARAK DOGRU YAZMAN GEREKIR !!!!




Neighbors have to be configured manually and BGP uses TCP port 179 for the connection.
In this lesson we’ll take a close look at the different “states” when two BGP routers try to become neighbors. Here they are:
  1. Idle:This is the first state where BGP waits for a “start event”. The start event occurs when someone configures a new BGP neighbor or when we reset an established BGP peering. After the start event, BGP will initialize some resources, resets a ConnectRetry timer and initiates a TCP connection to the remote BGP neighbor. It will also start listening for a connection in case the remote BGP neighbor tries to establish a connection. When successful, BGP moves to the Connect state. When it fails, it will remain in the Idle state.
  2. Connect: BGP is waiting for the TCP three-way handshake to complete. When it is successful, it will continue to the OpenSent state. In case it fails, we continue to the Active state. If the ConnectRetry timer expires then we will remain in this state. The ConnectRetry timer will be reset and BGP will try a new TCP three-way handshake. If anything else happens (for example resetting BGP) then we move back to the Idle state.
  3. Active: BGP will try another TCP three-way handshake to establish a connection with the remote BGP neighbor. If it is successful, it will move to the OpenSent state. If the ConnectRetry timer expires then we move back to the Connect state. BGP will also keep listening for incoming connections in case the remote BGP neighbor tries to establish a connection. Other events can cause the router to go back to the Idle state (resetting BGP for example).
  4. OpenSent: In this state BGP will be waiting for an Open message from the remote BGP neighbor. The Open message will be checked for errors, if something is wrong (incorrect version numbers, wrong AS number, etc.) then BGP will respond with a Notification message and jumps back to the Idle state. This is also the moment where BGP decides whether we use EBGP or IBGP (since we check the AS number). If everything is OK then BGP starts sending keepalive messages and resets its keepalive timer. At this moment, the hold time is negotiated (lowest value is picked) between the two BGP routers. In case the TCP session fails, BGP will jump back to the Active state. When any other errors occur (expiration of hold timer), BGP will send a notification message with the error code and jumps back to the Idle state. In case someone resets the BGP process, we also jump back to the Idle state.
  5. OpenConfirm: BGP waits for a keepalive message from the remote BGP neighbor. When we receive the keepalive, we can move to the established state and the neighbor adjacency will be completed. When this occurs, it will reset the hold timer. If we receive a notification message from the remote BGP neighbor then we fall back to the Idle state. BGP will keep sending keepalive messages.
  6. Established: The BGP neighbor adjacency is complete and the BGP routers will send update packets to exchange routing information. Every time we receive a keepalive or update message, the hold timer will be resetted. In case we receive a notification message we will jump back to the Idle state.
This whole process of becoming BGP neighbors can be visualized, this might be a bit easier then just reading about it. The official name of a “diagram” that shows the different states and we can move from one state to another is called a FSM (Finite State Machine). For BGP, it looks like this:
BGP states neighbor adjacency
Now you know about the different states, let’s take a look at some Cisco BGP routers to see what it actually looks like on two routers. I’ll use the following topology for this:
BGP R1 R2 AS1 AS2
Just two routers in two different autonomous systems. Before I configure BGP, let’s enable a debug:
R1, R2 #debug ip bgp
BGP debugging is on for address family: IPv4 Unicast
This will give us everything…
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
As soon as I do this you will see some debugging;
R1#
BGP: 192.168.12.2 active went from Idle to Active
BGP: 192.168.12.2 open active, local address 192.168.12.1
BGP: 192.168.12.2 open failed: Connection refused by remote host
BGP: 192.168.12.2 Active open failed - tcb is not available, open active delayed 9216ms (35000ms max, 60% jitter)
BGP: ses global 192.168.12.2 (0x4B43F3FC:0) act Reset (Active open failed).
BGP: 192.168.12.2 active went from Active to Idle
BGP: nbr global 192.168.12.2 Active open failed - open timer running
As soon as I configure BGP on R1 it will try to connect to R2. You can see the debug says that the state moves from Idle to Active (it doesn’t show the Connect state in the debug). When it fails, it falls back to the Idle state. Now let’s configure BGP on R2 as well so we can see a successful progress through the states:
R2(config)#router bgp 2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
Now look at the debug on R1:
R1#
BGP: 192.168.12.2 active went from Idle to Active
BGP: 192.168.12.2 open active, local address 192.168.12.1
BGP: ses global 192.168.12.2 (0x4B43F3FC:0) act Adding topology IPv4 Unicast:base
BGP: ses global 192.168.12.2 (0x4B43F3FC:0) act Send OPEN
BGP: 192.168.12.2 active went from Active to OpenSent
BGP: 192.168.12.2 active sending OPEN, version 4, my as: 1, holdtime 180 seconds, ID C0A80C01
BGP: 192.168.12.2 active rcv message type 1, length (excl. header) 34
BGP: ses global 192.168.12.2 (0x4B43F3FC:0) act Receive OPEN
BGP: 192.168.12.2 active rcv OPEN, version 4, holdtime 180 seconds
BGP: 192.168.12.2 active rcv OPEN w/ OPTION parameter len: 24
BGP: 192.168.12.2 active rcvd OPEN w/ optional parameter type 2 (Capability) len 6
BGP: 192.168.12.2 active OPEN has CAPABILITY code: 1, length 4
BGP: 192.168.12.2 active OPEN has MP_EXT CAP for afi/safi: 1/1
BGP: 192.168.12.2 active rcvd OPEN w/ optional parameter type 2 (Capability) len 2
BGP: 192.168.12.2 active OPEN has CAPABILITY code: 128, length 0
BGP: 192.168.12.2 active OPEN has ROUTE-REFRESH capability(old) for all address-families
BGP: 192.168.12.2 active rcvd OPEN w/ optional parameter type 2 (Capability) len 2
BGP: 192.168.12.2 active OPEN has CAPABILITY code: 2, length 0
BGP: 192.168.12.2 active OPEN has ROUTE-REFRESH capability(new) for all address-families
BGP: 192.168.12.2 active rcvd OPEN w/ optional parameter type 2 (Capability) len 6
BGP: 192.168.12.2 active OPEN has CAPABILITY code: 65, length 4
BGP: 192.168.12.2 active OPEN has 4-byte ASN CAP for: 2
BGP: nbr global 192.168.12.2 neighbor does not have IPv4 MDT topology activated
BGP: 192.168.12.2 active rcvd OPEN w/ remote AS 2, 4-byte remote AS 2
BGP: 192.168.12.2 active went from OpenSent to OpenConfirm
BGP: 192.168.12.2 active went from OpenConfirm to Established
BGP: ses global 192.168.12.2 (0x4B43F3FC:1) act Assigned ID
BGP: ses global 192.168.12.2 (0x4B43F3FC:1) Up
%BGP-5-ADJCHANGE: neighbor 192.168.12.2 Up
Above you can see that the BGP state moves from Idle to Active and then to OpenSent. Some Open messages are sent and received, the BGP routers are exchanging some of their capabilities. From there we move to the OpenConfirm and Established state. Finally you see the BGP neighbor as up. On R2 we see something similar:
R2#
BGP: 192.168.12.1 passive open to 192.168.12.2
BGP: 192.168.12.1 passive went from Idle to Connect
BGP: ses global 192.168.12.1 (0x4B269374:0) pas Setting open delay timer to 60 seconds.
BGP: ses global 192.168.12.1 (0x4B269374:0) pas read request no-op
BGP: 192.168.12.1 passive rcv message type 1, length (excl. header) 34
BGP: ses global 192.168.12.1 (0x4B269374:0) pas Receive OPEN
BGP: 192.168.12.1 passive rcv OPEN, version 4, holdtime 180 seconds
BGP: 192.168.12.1 passive rcv OPEN w/ OPTION parameter len: 24
BGP: 192.168.12.1 passive rcvd OPEN w/ optional parameter type 2 (Capability) len 6
BGP: 192.168.12.1 passive OPEN has CAPABILITY code: 1, length 4
BGP: 192.168.12.1 passive OPEN has MP_EXT CAP for afi/safi: 1/1
BGP: 192.168.12.1 passive rcvd OPEN w/ optional parameter type 2 (Capability) len 2
BGP: 192.168.12.1 passive OPEN has CAPABILITY code: 128, length 0
BGP: 192.168.12.1 passive OPEN has ROUTE-REFRESH capability(old) for all address-families
BGP: 192.168.12.1 passive rcvd OPEN w/ optional parameter type 2 (Capability) len 2
BGP: 192.168.12.1 passive OPEN has CAPABILITY code: 2, length 0
BGP: 192.168.12.1 passive OPEN has ROUTE-REFRESH capability(new) for all address-families
BGP: 192.168.12.1 passive rcvd OPEN w/ optional parameter type 2 (Capability) len 6
BGP: 192.168.12.1 passive OPEN has CAPABILITY code: 65, length 4
BGP: 192.168.12.1 passive OPEN has 4-byte ASN CAP for: 1
BGP: nbr global 192.168.12.1 neighbor does not have IPv4 MDT topology activated
BGP: 192.168.12.1 passive rcvd OPEN w/ remote AS 1, 4-byte remote AS 1
BGP: ses global 192.168.12.1 (0x4B269374:0) pas Adding topology IPv4 Unicast:base
BGP: ses global 192.168.12.1 (0x4B269374:0) pas Send OPEN
BGP: 192.168.12.1 passive went from Connect to OpenSent
BGP: 192.168.12.1 passive sending OPEN, version 4, my as: 2, holdtime 180 seconds, ID C0A80C02
BGP: 192.168.12.1 passive went from OpenSent to OpenConfirm
BGP: 192.168.12.1 passive went from OpenConfirm to Established
BGP: ses global 192.168.12.1 (0x4B269374:1) pas Assigned ID
BGP: nbr global 192.168.12.1 Stop Active Open timer as all topologies are allocated
BGP: ses global 192.168.12.1 (0x4B269374:1) Up
%BGP-5-ADJCHANGE: neighbor 192.168.12.1 Up
The output of these debug messages are nice and easy to read. If for some reason your neighbor adjacency doesn’t appear, these debugs can be helpful to solve the problem.



I created a loopback interface with network 11.11.11.11 /32. BGP uses the network command to advertise 11.11.11.0 /24. This network will never be placed in the BGP table since the subnet mask doesn’t match:
R1#show ip bgp 11.11.11.11
% Network not in table
Be aware of this. Make sure you type the exact network address and subnet mask when advertising something in BGP. Let’s fix this:
R1(config)#router bgp 1
R1(config-router)#no network 11.11.11.0 mask 255.255.255.0
R1(config-router)#network 11.11.11.11 mask 255.255.255.255
With the correct network command, BGP will be able to advertise this network in the BGP table:

R1#show ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 5
Paths: (1 available, best #1, table default)
  Advertised to update-groups:
     1
  Local
    0.0.0.0 from 0.0.0.0 (192.168.12.1)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

Border Gateway Protocol (BGP) uses very large topology due to using high cpu and very late reaction time.

BGP L4 ve üstü bir protocokoldür.
L1-2-3 e karismaz. Bunlarin saglanmasi yeterlidir. Nasil olacagini belirlemez.
Yani komsuluk kurulmasi için "komsuya erisebileyim yeter" der.

Yani komsuluk kurulmasi için "komsuya erisebileyim yeter" der.

(Ama Ospf L3 e müdahele ederdi, ayni subnet de olucaz der mesela.)

Onun içindir ki komsuluk iliskisi kurulurken DIREK BAGLI OLMA ZORUNLULUGUMUZ
YOKTUR.

BGP AS bilgisini kullanarak Routing Loop oluşmasınıda engellemektedir. Eğer bir update bir AS i terk ederse o AS numarası bu update’ e eklenir. Eğer aynı update tekrar aynı AS’ e geri dönerse Router tarafından discard edilir yani bu update bilgisi değerlendirilmez. Böylece Routing Loop engellenmiş olur.

Aynı zamanda AS bilgisi yol seçimi içinde kullanılır. Hemen size RIP (Routing Information Protocol) örneğini vermek isterim. RIP bir hedef networke gitmek için en iyi yol seçini yaparken atlayacağı Router sayısına yani Hop Count’ a bakardı. Bu değerin en azını seçer ve en iyi yol olarak orayı kullanırdı. BGP de bir hedef networke giderken atlayacağı AS sayısına bakacak ve en az AS sayısını kullanarak hedef networke erişmiş olacak. Böylece BGP ye bir PATH-VECTOR routing protokol diyebiliriz.

IBGP full mesh olmalıdır ve herkes birbiriyle komsuluk kurmak zorundadır , loop engelleme metodu olarak bu yontem kullanılır.

L3 üstü bir protokoldür. BUnlarla ugrasmaz. Bu da bir farklilik.
Bgp, L1-2-3 ün hazir olmasini ister.



Route Reflector 

Route reflector bir interfaceden öğrendiğin bilgiyi broadcast gibi diğer interfacelerden göndermektek
 IBGP Route Reflector Route Update

 AS 123 IBGP Route Reflector



hostname R2
!
ip cef
!
interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.168.23.2 255.255.255.0
!
router bgp 123
 bgp log-neighbor-changes
 neighbor 192.168.12.1 remote-as 123
 neighbor 192.168.23.3 remote-as 123
 neighbor 192.168.12.1 route-reflector-client
 neighbor 192.168.23.3 route-reflector-client
!
end


Next-hop self ebgp'den ibgp ye giden paketlerde ibgp tarafında destination route'nın güncellenmeme problemini ortadan kaldırmak.

**** R2 'in ipsi 1.1.1.2 olsun R2'altaki komut yazıldığında R1 routerın default gw'i 1.1.1.2 olur.
router bgp 65001
neighbor 1.1.1.1 default-originate

 

IBGP Komsuluk :


R2 R3 R4 full mesh IBGP

R2 ile R4 arasında IBGP komsuluk kurulmak zorunludur. Yoksa R3 üzerinde routing tablolarını paylaşmazlar .

 IBGP does not advertise prefixes from one IBGP neighbor to another IBGP neighbor. This is called BGP split horizon. Bunların cozumu icin route reflector ve  COnfederation methotları kullanılır.

R1#
conf t
router bgp 100 ! Bizim As !
neighbor 12.0.0.2 remote-as 100 ! KOmsunun AS si !
no auto-summary

EBGP KOmsuluk :

R2#
conf t
router bgp 100 ! Bizim As !
neighbor 12.0.0.1 remote-as 200 ! KOmsunun AS si !
no auto-summary

Gördügümüz farkli AS den biriyle komsu olabiliyoruz ve buna EBGP diyoruz.

router bgp 100
neighbor 2.2.2.2 remote-as 100
neighobr 2.2.2.2 update-source lo1 ( Bu komşum, beni lo1 den tanıyor demektir)

EBGP-MULTIHOP
=============

BGP AS1 AS2 AS3 AS4

R4'den sadece 4.4.4.4 adresini anons edeceğiz.

R1
hostname R1
!
interface fastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
!
interface fastEthernet0/1
 ip address 192.168.13.1 255.255.255.0
!
router bgp 1
 neighbor 192.168.12.2 remote-as 2
 neighbor 192.168.13.3 remote-as 3
!
end
R2
hostname R2
!
interface fastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface fastEthernet0/1
 ip address 192.168.24.2 255.255.255.0
!
router bgp 2
 neighbor 192.168.12.1 remote-as 1
 neighbor 192.168.24.4 remote-as 4
!
end
R3:
hostname R3
!
interface fastEthernet0/0
 ip address 192.168.13.3 255.255.255.0
!
interface fastEthernet0/1
 ip address 192.168.34.3 255.255.255.0
!
router bgp 3
 neighbor 192.168.13.1 remote-as 1
 neighbor 192.168.34.4 remote-as 4
!
end
R4:

hostname R4
!
interface Loopback 0
 ip address 4.4.4.4 255.255.255.255
!
interface fastEthernet0/0
 ip address 192.168.24.4 255.255.255.0
!
interface fastEthernet0/1
 ip address 192.168.34.4 255.255.255.0
!
router bgp 4
 network 4.4.4.4 mask 255.255.255.255
 neighbor 192.168.24.2 remote-as 2
 neighbor 192.168.34.3 remote-as 3
!
end

R3#show ip bgp
BGP table version is 2, local router ID is 192.168.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  4.4.4.4/32       192.168.13.1                           0 1 2 4 i
*>                  192.168.34.4             0             0 4 i
EBGP komsuluk kurulurken aklimizda bulunmasi gereken birsey var.

Normalde ebgp komsuluk direk bagli olmasi gerekir mantigi ile çalisir bgp.

Onun için eger,

R1 AS 100 kullaniyor, R2 ise AS 200 kullaniyor ise,
ve yine loopback leri kullancak olursak,

r1#

conf
router bgp 100
negigbor 2.2.2.2 remote-as 200
neigbohr 2.2.2.2 update-source lo1
no auto-summary

bu yeterli gelmeyecektir.

ÇÜnkü router umuz ebgp bir komsuluk kurulacagini anlar anlamaz !!!!!!!!
Giden istek paketinin TTL degerini 1 yapar.
(ibgp komsuluk için ise 255 dir)

R2 nin fiziksel interface bu paketi alir,
TTL degerini 1 azaltir yani 0 olur,
dolayisiyla loopback e iletmez.
Ve komşuluk kurulmaz. Ve Active durumda takılıp kalma sebeplerinden biri de budur.


Onun için bu TTL degerini artirmaliyiz.


r1#

conf
router bgp 100
negigbor 2.2.2.2 remote-as 200
neigbohr 2.2.2.2 update-source lo1
neigbohr 2.2.2.2 ebgp-multihop 2
no auto-summary

Bu komut ile TTL degerini 2 yaptık.
Ebgp komşumuz 20 router ötemizdeyse ona göre TTL degerini artırabiliriz.

Send OPEN message that is contains

Bgp Version Numarasi
AS
Hold Down Timer
Bgp Identifier
OPerational Parameters

Loopback addresses are used when establishing a neighborhood connection. The reason is loopback interface is up interface for a long.

Bgp uses 179 port.Between  64512-65535 are private ASN numbers.

external  bgp dan internal'a giderken her zaman next hop self girilmek zorundadir.Amaci EBGP DEN ALDIGINI IBGP KOMSUNA GÖNDERIRKEN NEXT HOP U DEGISTIR demektir.

Yani Route Reflector ımızı Client, Non-Client lardan aldigi ROute larin
NEXT HOP KISMINI DEGISTIRMEZ !!!

IBGP tarafında next-hop self komutu ile externaldan gelen next hop bilgisi igbp komusumuzun ip'si ile değistirilir.

NEXT HOP SELF

BGP Next Hop Self Demo Topology

hostname R1
!
interface fastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
!
router bgp 12
 neighbor 192.168.12.2 remote-as 12
!
end
hostname R2
!
interface fastEthernet1/0
 ip address 192.168.12.2 255.255.255.0
!
interface fastEthernet0/1
 ip address 192.168.23.1 255.255.255.0
!
router bgp 12
 neighbor 192.168.12.1 remote-as 12
 neighbor 192.168.23.3 remote-as 3
 neighbor 192.168.12.1 next-hop-self
!
end
hostname R3
!
interface fastEthernet0/0
 ip address 192.168.23.3 255.255.255.0
!
router bgp 3
 neighbor 192.168.23.2 remote-as 12
 network 3.3.3.0 mask 255.255.255.0
!
end

Ornegin

Bgp Synchronization Example Topology Ibgp Ebgp


R5 Üzerinden R1'in loopback 1.1.1.1 ipsine erişmek istersek

R1:
hostname R1
!
ip cef
!
interface FastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
!
router bgp 1
 bgp log-neighbor-changes
 network 1.1.1.0 mask 255.255.255.0
 neighbor 192.168.12.2 remote-as 2
!
end
R2:
hostname R2
!
ip cef
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.168.23.2 255.255.255.0
!
router ospf 1
 network 2.2.2.0 0.0.0.255 area 0
 network 192.168.23.0 0.0.0.255 area 0
!
router bgp 2
 bgp log-neighbor-changes
 neighbor 3.3.3.3 remote-as 2
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 3.3.3.3 next-hop-self
 neighbor 4.4.4.4 remote-as 2
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 4.4.4.4 next-hop-self
 neighbor 192.168.12.1 remote-as 1
!
end
R3:
hostname R3
!
ip cef
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.23.3 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.168.34.3 255.255.255.0
!
router ospf 1
 network 3.3.3.0 0.0.0.255 area 0
 network 192.168.23.0 0.0.0.255 area 0
 network 192.168.34.0 0.0.0.255 area 0
!
router bgp 2
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 2
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 4.4.4.4 remote-as 2
 neighbor 4.4.4.4 update-source Loopback0
!
end
R4
hostname R4
!
ip cef
!
interface Loopback0
 ip address 4.4.4.4 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.34.4 255.255.255.0
!
interface FastEthernet0/1
 ip address 192.168.45.4 255.255.255.0
!
router ospf 1
 network 4.4.4.0 0.0.0.255 area 0
 network 192.168.34.0 0.0.0.255 area 0
!
router bgp 2
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 2
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 3.3.3.3 remote-as 2
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 3.3.3.3 next-hop-self
 neighbor 192.168.45.5 remote-as 3
!
end
R5

hostname R5
!
ip cef
!
interface FastEthernet0/0
 ip address 192.168.45.5 255.255.255.0
!
router bgp 3
 bgp log-neighbor-changes
 neighbor 192.168.45.4 remote-as 2
 network 192.168.45.0 mask 255.255.255.0
!
end

BGP YOL SECIMI

1.En yüksek WEIGHT değeri önceliklidir.
2.En yüksek LOCAL PREF değeri önceliklidir.
3.Network veya redistrubute komutları kullanarak yapılan BGP dağıtımı, aggregate komutu ile yapılana göre önceliklidir.
4.En kısa AS PATH tercih edilir.
5.En düşük origin type seçilir, IGP , EGP ye göre düşüktür, EGP ise INCOMPLETE’e göre düşüktür. (Eğer BGP içine eklerken network komutu ile eklersek “i” olarak, redistribute edersek”?” olarak ilgili route BGP ye gönderilir)
6.En düşük MED değeri önceliklidir.
7.EBGP nin Administrative Distance değeri (20) , IBGP den daha düşük olduğu için (200) , EBGP;  IBG’ye göre daha  önceliklidir.
8.En düşük IGP metriği tercih edilir.
9.BGP Multipath olması tercih edilir.
10.Next Hop olarak önce öğrendiği router tercih edilir.
11.Düşük Router ID den gelen route tercih edilir.
12.En düşük cluster listesi uzunluğu tercih edilir.

13.Düşük IP adresine sahip komşudan gelen route tercih edilir.

BGP Temel Öğeleri (Attribute)

WEIGHT Cisco’ya özgü parametredir, hiçbir route güncellemesinde taşınmaz yani sadece router’ın lokalinde kalır. Parametre 0 dan 65535 arası değere ayarlanabilir default olarak 32768’dir.Weight değeri yüksek olan route en iyi route seçilir.

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 weight 500


router bgp 1
 neighbor 192.168.12.2 remote-as 2
 neighbor 192.168.13.3 remote-as 2
 neighbor 192.168.13.3 route-map SETWEIGHT in
!
route-map SETWEIGHT permit 10
 match ip address 1
 set weight 400
!
route-map SETWEIGHT permit 20
 set weight 0
!
access-list 1 permit 22.22.22.0 0.0.0.255



LOCAL PREF

R3(config)#router bgp 2
R3(config-router)#bgp default local-preference 600
The default local preference is 100 and you can change it if you like with the bgp default local-preference command.
R4#show ip bgp 
BGP table version is 3, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i1.1.1.0/24       3.3.3.3                  0    600      0 1 i
* i                 2.2.2.2                  0    100      0 1 i


LOCAL Pref öğeside isminden  anlaşıldığı üzere lokaldir  ancak Weight öğesinden farklı olarak AS içinde yayılır. Bu öğe AS ler arası taşınmaz, default değeri 100’dür ve  lokal pref değeri yüksek olan route en iyi route seçilir.


AS PATH


AS PATH öğesi AS numaralarının listesinden ibarettir. Bu liste, route için geçtiği AS ‘lerin eklenmesi ile oluşturulur. AS Path listesi kısa olan route en iyi route seçilir.

R2#show ip bgp 
BGP table version is 2, local router ID is 192.168.23.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.0/24       192.168.23.3             0             0 1 i
*>                  192.168.12.1             0             0 1 i
In the table above you can see that it prefers 192.168.12.1 as its path. Let’s change the AS path so that we’ll use 192.168.23.3 as the preferred path.
R1(config)#route-map PREPEND permit 10
R1(config-route-map)#set as-path prepend 1 1 1 1 1
R1(config-route-map)#exit
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map PREPEND out
Here’s an example for you. First, create a route-map and use set as-path prepend to add your own AS number multiple times.
Don’t forget to add the route-map to your BGP neighbor configuration and since you are sending this to your remote neighbor it should be outbound!
R2#show ip bgp 
BGP table version is 2, local router ID is 192.168.23.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       192.168.23.3             0             0 1 i
*                   192.168.12.1             0             0 1 1 1 1 1 1 i
Now we see that 192.168.23.3 is the next hop IP address that we use. You can also see that the AS Path has become longer for the second entry.

MED Attribute


This is the BGP configuration, nothing special so far.
R2#show ip bgp 
BGP table version is 2, local router ID is 192.168.23.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.0/24       192.168.23.3             0             0 1 i
*>                  192.168.12.1             0             0 1 i
You have seen the example above before. R2 prefers the path through 192.168.12.1. Note that the metric (MED) is 0. Let’s play with the MED now:
R1(config)#route-map MED permit 10
R1(config-route-map)#set metric 700   
R1(config-route-map)#exit

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map MED out
R3(config)#route-map MED permit 10
R3(config-route-map)#set metric 500
R3(config-route-map)#exit

R3(config)#router bgp 1
R3(config-router)#neighbor 192.168.23.2 route-map MED out
I’ll use route-maps so that R1 advertises everything with a med of 700 and R3 will advertise everything with a med of 500.
R2#show ip bgp 
BGP table version is 2, local router ID is 192.168.23.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.0/24       192.168.12.1           700             0 1 i
*>                  192.168.23.3           500             0 1 i
You can see R2 prefers the path through 192.168.23.3 because the med is lower. That’s all there is to it.


router bgp 123
bgp default local-preference 200 (direk ana router bgp icin)


Bize gelen dedikodunun daha önceden bizim uydurdugumuz oldugunu anlayamayız.Ve LOOP olur.Onun için ibgp komsuluk iliskisi FULL MESH olmak zorundadir demisler.

Yani 10 router her biri birbiriyle arkadas ise. R1 bisi söyleyince diger 9 router ögrenmis olacaktir.Kimsenin kimseye bisi demesi gerekmez. Loop da olmaz.Böyle bir mantik kurmuslar. Mantiklida.10 router luk bir ortamda herkes herkes ile komsuluk kurarsa.45 komsuluk olmus olacaktir isin sonunda. n(n-1)/2.Yalniz bir sürü komsuluk kurmak = bir sürü para demektir.Onun için bir kaç çözüm getirmisler.Bunlardan birisi Route Reflector digeri ise COnfederation.

Route Reflector un aktaracağı bilgiyi kimden ögrendigi önemlidir.

Eger EBGP birinden ögrenmis ise ---> EBGP, CLIENT, NON-CLIENT a söyleyebilir.
Eger CLIENT birinden ögrenmis ise ---> EBGP,CLIENT,NON-CLIENT a söyleyebilir.
Eger NON-CLIENT birinden ögrenmis ise ---> EBGP, CLIENT, a söyleyebilir.

Dikkat ettiyseniz NON-CLIENT dan ( Ekibinde olmayan birinden) ögrendigini
baska bir NON-CLIENT a söylemiyor.

Sadece bunu aklimizda tutsak bile yeterlidir.



ROUTE REFLECTOR

IBGP'de herkes birbiriyle komsuluk kurmalıydı bu cok uzun bu için route reflector diye bir şey çıkartılmış.Bir tane RR seçiyoruz, Route reflector bir interfaceden öğrendiğin bilgiyi broadcast gibi diğer interfacelerden göndermektir..

Ornek

Üsteki topolojide interfaceleri ospf ile haberleştireceğiz nexthop adresine erişmesi için sonrasında R1 RR yapıcaz R2,R3,R4 client yapıcaz ve broadcast gibi öğrendiğimiz rotaları dağıtacağız , IBGP kullanıcaz. Redistribute connected kullanıcaz IBGP içerisinde.

R2

interface FastEthernet1/0
 ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet1/1
 ip address 22.22.22.1 255.255.255.0
!
router ospf 1
 network 2.2.2.0 0.0.0.255 area 0
!
router bgp 55555
 redistribute connected
 neighbor 2.2.2.1 remote-as 55555


R3

interface FastEthernet1/0
 ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet1/1
 ip address 33.33.33.1 255.255.255.0
!
router ospf 1
 network 3.3.3.0 0.0.0.255 area 0
!
router bgp 55555
 redistribute connected
 neighbor 3.3.3.1 remote-as 55555

R4

interface FastEthernet1/0
 ip address 4.4.4.4 255.255.255.0
!
interface FastEthernet1/1
 ip address 44.44.44.1 255.255.255.0
!
router ospf 1
 network 4.4.4.0 0.0.0.255 area 0
!
router bgp 55555
 redistribute connected
 neighbor 4.4.4.1 remote-as 55555

R1

interface FastEthernet1/0
 ip address 2.2.2.1 255.255.255.0
!
interface FastEthernet1/1
 ip address 3.3.3.1 255.255.255.0
!
interface FastEthernet2/0
 ip address 4.4.4.1 255.255.255.0
!
router ospf 1
 network 2.2.2.0 0.0.0.255 area 0
 network 3.3.3.0 0.0.0.255 area 0
 network 4.4.4.0 0.0.0.255 area 0
!
router bgp 55555
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 55555
 neighbor 2.2.2.2 route-reflector-client
 neighbor 3.3.3.3 remote-as 55555
 neighbor 3.3.3.3 route-reflector-client
 neighbor 4.4.4.4 remote-as 55555
 neighbor 4.4.4.4 route-reflector-client

-----------------

Redundant Route Reflectors





R1 ve R2 route reflectorlerimiz ile cihazlarımız birbirine üzerlerindeki routeları gonderiyor  , yine ospf ile komşuluklar kuruluyor . IBGP protokolu ile komsuluklar kuruluyor.


R3


interface Loopback0
 ip address 11.11.11.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 1.1.1.2 255.255.255.252
!
interface FastEthernet0/1
 ip address 1.1.1.6 255.255.255.252
!
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp router-id 1.1.1.2
 bgp log-neighbor-changes
 network 11.11.11.0 mask 255.255.255.0
 neighbor 1.1.1.1 remote-as 55555
 neighbor 1.1.1.1 update-source FastEthernet0/0
 neighbor 1.1.1.5 remote-as 55555
 neighbor 1.1.1.5 update-source FastEthernet0/1
 no auto-summary


R4 :

interface Loopback0
 ip address 12.12.12.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 1.1.1.14 255.255.255.252
!
interface FastEthernet0/1
 ip address 1.1.1.10 255.255.255.252
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp router-id 1.1.1.10
 bgp log-neighbor-changes
 network 12.12.12.0 mask 255.255.255.0
 neighbor 1.1.1.9 remote-as 55555
 neighbor 1.1.1.9 update-source FastEthernet0/1
 neighbor 1.1.1.13 remote-as 55555
 neighbor 1.1.1.13 update-source FastEthernet0/0
 no auto-summary

R5

interface Loopback0
 ip address 13.13.13.1 255.255.255.0
!
interface FastEthernet1/0
 ip address 1.1.1.18 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.22 255.255.255.252
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp router-id 1.1.1.18
 bgp log-neighbor-changes
 network 13.13.13.0 mask 255.255.255.0
 neighbor 1.1.1.17 remote-as 55555
 neighbor 1.1.1.17 update-source FastEthernet1/0
 neighbor 1.1.1.21 remote-as 55555
 neighbor 1.1.1.21 update-source FastEthernet1/1
 no auto-summary

R6

interface Loopback0
 ip address 14.14.14.1 255.255.255.0
!
interface FastEthernet1/0
 ip address 1.1.1.30 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.26 255.255.255.252
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp router-id 1.1.1.26
 bgp log-neighbor-changes
 network 14.14.14.0 mask 255.255.255.0
 neighbor 1.1.1.25 remote-as 55555
 neighbor 1.1.1.25 update-source FastEthernet1/1
 neighbor 1.1.1.29 remote-as 55555
 neighbor 1.1.1.29 update-source FastEthernet1/0
 no auto-summary

R1:

interface FastEthernet0/0
 ip address 1.1.1.1 255.255.255.252
!
interface FastEthernet0/1
 ip address 1.1.1.9 255.255.255.252
!
interface FastEthernet1/0
 ip address 1.1.1.17 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.25 255.255.255.252
!
interface FastEthernet2/0
 ip address 100.100.100.1 255.255.255.0
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp log-neighbor-changes
 neighbor 1.1.1.2 remote-as 55555
 neighbor 1.1.1.2 update-source FastEthernet0/0
 neighbor 1.1.1.2 route-reflector-client
 neighbor 1.1.1.10 remote-as 55555
 neighbor 1.1.1.10 update-source FastEthernet0/1
 neighbor 1.1.1.10 route-reflector-client
 neighbor 1.1.1.18 remote-as 55555
 neighbor 1.1.1.18 update-source FastEthernet1/0
 neighbor 1.1.1.18 route-reflector-client
 neighbor 1.1.1.26 remote-as 55555
 neighbor 1.1.1.26 update-source FastEthernet1/1
 neighbor 1.1.1.26 route-reflector-client
 neighbor 100.100.100.2 remote-as 55555
 neighbor 100.100.100.2 update-source FastEthernet2/0
 no auto-summary

R2:

interface FastEthernet0/0
 ip address 1.1.1.13 255.255.255.252
!
interface FastEthernet0/1
 ip address 1.1.1.5 255.255.255.252
!
interface FastEthernet1/0
 ip address 1.1.1.29 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.21 255.255.255.252
!
interface FastEthernet2/0
 ip address 100.100.100.2 255.255.255.0
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
!
router bgp 55555
 bgp log-neighbor-changes
 neighbor 1.1.1.6 remote-as 55555
 neighbor 1.1.1.6 update-source FastEthernet0/1
 neighbor 1.1.1.6 route-reflector-client
 neighbor 1.1.1.14 remote-as 55555
 neighbor 1.1.1.14 update-source FastEthernet0/0
 neighbor 1.1.1.14 route-reflector-client
 neighbor 1.1.1.22 remote-as 55555
 neighbor 1.1.1.22 update-source FastEthernet1/1
 neighbor 1.1.1.22 route-reflector-client
 neighbor 1.1.1.30 remote-as 55555
 neighbor 1.1.1.30 update-source FastEthernet1/0
 neighbor 1.1.1.30 route-reflector-client
 neighbor 100.100.100.1 remote-as 55555
 neighbor 100.100.100.1 update-source FastEthernet2/0
 no auto-summary

-----------------
reflector
router#router bgp 100
router(config-router)#neighbor 120.10.55.1 remote-as 100
router(config-router)#neighbor 120.10.55.1 route-reflector-client
eğer altına cluster-id eklersek o cluster'a üye etmiş oluruz.
router(config-router)#bgp Cluster-id 2000

client
router#router bgp 100
router(config-router)#bgp Cluster-id 2000
router(config-router)#neighbor 120.10.10.1 remote-as 100


Cisco;

EBGP
router bgp 65051
 bgp log-neighbor-changes
 network 10.34.20.0 mask 255.255.255.0(your network)
 neighbor 172.19.0.1 remote-as 65000
no auto-summary

IBGP

router bgp 65000
 bgp log-neighbor-changes
 network 10.34.20.0 mask 255.255.255.0(your network)
 neighbor 172.19.0.1 remote-as 65000
no auto-summary

OR

If you want to use loopback interface for bgp establishing.



i
BGP Confederation
-------------------------

Aynı AS içerisindeki ibgp komşuluklarının Full Mesh bir yapıya sahip
olması gerektiğini daha önceden söylemiştik .

Loop engelleme sistemi normalde ibgp ortamında olmadıgı için böyle bir zorunluluk
getirmişler.

Ama bir sürü komşuluk kurmak hiç de uygulanabilir birşey olmadığından buna çözüm olarak

Route Reflection
ve
Confederation

Çözümü getirmişler.

Confederation genelde çok daha büyük AS lerde kullanılan bir sistemdir.

Route Reflector ise Confederation a göre daha populerdir.

İkisini aynı anda kullanmak ise mümkündür.


Neyse gelelim konumuza...

AS miz içinde 20 tane Router oldugunu düşünelim.

Bunların bir biriyle komşu olması demek

nx(n-1)/2 kadar komşuluk demektir.

20x(20-1)/2 = 190 yapıyor sanırım.

Küçüçük AS mizde bir sürü komşuluk oldu.

Route Reflector uygulaysaydık Bir tane RR seçerdik
digerlerini Client yapardık olur biterdi

Tabi bu her zaman mantıklı bir çözüm olmayabilir.

Onun Yerine şunu yapalım.

AS mizi ikiye bölelim.

OKuldaki bir sınıfı bölmek gibi aynı.

4C sınıfının 20 kişilik oldugunu düşünelim.

Sınıfı ikiye bölelim.

Ve her grupda 10 kişi olsun.

Hala aynı sınıfın içindeyiz ama.

Şimdi bu iki gruba isimler verelim.


Mesela 4C1 e 4C2 olsun

İşte AS miz içindeki Router larıda böyle bölüp gruplaştırabiliriz.

Peki diyelimki önceden AS numaramız 19 idi.

Şimdi içerdeki Gruplara ayırdıklarımıza ne vericez AS olarak ?

Bunun için Private ASN ler var. 64512-65535 Arası.

Bu kadar basit.

Bunlara SUB-AS diyelim.

Her SUB-AS kendi içinde hala FUll MESH olmak zorunda.

Asıl güzel yanına gelelim.

Biz bu iki grubu birbirine baglayabiliriz.

Bunlar iki farklı AS ( aslında SUB-AS ) oldugundan ebgp komşuluk kurar "gibi" olucaz !

Her Grupdan bir Router belirleriz ve bunları birbirine baglarız.

Bu ikisi arasındaki ilişkiyede cBGP denir

cBGP aslında ibgp ve ebgp nin karışımıyla elde edilmiş bir terim.

Çünkü her ikisinin özelliğinide taşır.

BUnları bilirsek gerisi önemli değil.


cBGP için bilmemiz gereken kuralları yazalım !

Kural 1 - cBGP komşular birbirinden aldıkları route ların
NEXT HOP kısmını değiştirmezler kendi ibgp
komşularına yollarken. ( ibgp gibi)

Kural 2 - Ama olsun NEXT-HOP-SELF komutu burda işe yarıyor

Kural 3 - cBGP komşuluk kurulurken ebgp kuralları geçerlidir.
Gerekirse ebgp multihop yada disable-connected-check uygulanacaktır.


Ve SUB-AS ler arası route lar gönderilirken bu verdiğimiz

Private ASN ler PREPEND edilir.

Böylece hangi SUB-AS ne den geldiğini biliriz.

KOnfigurasyon ise Çok Basittir.


---

TOPOLOGY olarak bunu kullanalım.

R1 Router muzda yapacağımız konfigurasyon da değişiklik yok.

Kod:
r1#sh run | sec bgp

 router bgp 13
 network 1.1.1.0 mask 255.255.255.0
 neighbor 12.0.0.2 remote-as 19
 neighbor 13.0.0.3 remote-as 19

Şimdi GELELIM AS 19 içinde yani Confederation Kullandığımız AS ye ...



Kod:
r2#sh run | sec bgp

 router bgp 65001
 bgp confederation identifier 19
 bgp confederation peers 65002

 neighbor 3.3.3.3 remote-as 65002
 neighbor 3.3.3.3 disable-connected-check
 neighbor 3.3.3.3 update-source Loopback1
 neighbor 3.3.3.3 next-hop-self

 neighbor 12.0.0.1 remote-as 13
 neighbor 24.0.0.4 remote-as 65001
 neighbor 24.0.0.4 next-hop-self
 neighbor 25.0.0.5 remote-as 65001
 neighbor 25.0.0.5 next-hop-self

Kod:
r3#sh run | sec bgp

 router bgp 65002
 bgp confederation identifier 19
 bgp confederation peers 65001

 neighbor 2.2.2.2 remote-as 65001
 neighbor 2.2.2.2 disable-connected-check
 neighbor 2.2.2.2 update-source Loopback1
 neighbor 2.2.2.2 next-hop-self
 neighbor 13.0.0.1 remote-as 13

 neighbor 36.0.0.6 remote-as 65002
 neighbor 36.0.0.6 next-hop-self
 neighbor 37.0.0.7 remote-as 65002
 neighbor 37.0.0.7 next-hop-self


R4-5-6-7 nin Konfigurasyonu yazmaaya gerek yok sanırım.

Şİmdi Bir Kaç Şeyi Açıklayalım.


router bgp 65001 ---> İlk Önce Private ASN mizi Yazacağız.

bgp confederation identifier 19 --> Ardından GErçek ASN mizi Yazıcaz.

bgp confederation peers 65002 ---> Ve burda ise AS içindeki Grupları yazıcaz.
Birden fazla olabilirdi.


R2-R4-R5 kendi arasında Full Mesh ibgp komşuluk kuracaklardır.

Ve SUB-AS olarak da 65001 kullanacaklar.


R3-R6-R7 kendi arasında Full Mesh ibgp komşuluk kuracaklardır.

Ve SUB-AS olarak da 65002 kullanacaklar.



---

Farklı SUB-AS lerden iki Router un komşu olmasına cBGP dedik.

Ve yukarda görüldüğü gibi

next-hop-self komutunu girdik.

Böylece Kendi aralarında Route alıp verirken Next Hop Kısmını Değiştirecekler.


Bir örnekle konuyu kapatalım.

R6 nın 6.6.6.0/24 networkunu yolladıgını görüyruz.

R6 Router umuz R3-R5 ile ibgp komşular.

R7 bunu alınca biliyoruzki Split Horizon dan dolayı R3 e falan göndermez.

R3 ise bunu alınca R2 YE GÖNDERİR !!!

ÇÜnkü o onun cBGP komşusudur.

Bu özelliği ile ebgp ye benzer.

Ama gönderirken next-hop degiştirmez.
Bu özelliği ile de ibgp ye benzer.

Ama biz next-hop-self kullanabildik
Bu özelliğide ebgp dir.

İkisi arası komşuluk kurulurken ise
ebgp kuralları geçerlidir dedik.
disable-connected-check ile de bunu gördük.

Peki 6.6.6.0/24 network u R4 de Nasıl Gözükür..



Kod:
r4#sh ip bgp

*>i6.6.6.0/24       24.0.0.2                 0    100      0 (65002) i
(65002) ile bunun SUB-AS den geldiğini gördük

Güzel bir LOOP engelleme yöntemidir.

Bu SUB-AS bilgisi sadece bizim AS 19 içinde gezer.

R2-3 bunu R1 e yollarken Siler...

R1 in bizim içimizi bilmesine gerek yoktur.



Kod:
r1#sh ip bgp

*  6.6.6.0/24       12.0.0.2                               0 19 i
*>                  13.0.0.3                               0 19 i
Görüldüğü gibi R1 router umuzda bu bilginin AS 19 dan geldiği bellidir sadece.




Yapılandırmaya girmeden önce konuyu biraz daha açalım. RouterA bizim çıkış routerımız, SP-A birincil hat, SP-B ise yedek hat olsun ve bu routerlara doğrudan bağlı bir B routerı olsun. RouterA üzerinde dış networke çıkan paketlerin 1. rotayı tercih etmesi için farklı yöntemler uygulanabilir şimdilik burda RouterA üzerinde local_pref değeri ile oynanıp dış dünyaya yollanılan paketler bu yoldan gönderilmeye başlandı diyelim. Dış dünyadan bize dönen paketler için ise herhangi bir durum belirtmemiş oluyoruz. Yani B routerına giden bir paket SP-A üzerinden gidebilecken ordan gelen bir paket SP-B üzerinden bize geri dönebilcek. BGP anonslarımız da SP-A üzerinden yapılan anonsları daha iyi olarak göstermek için SP-B ye yapılan anonslarda networkümüzü daha uzakta göstermemiz gerekmektedir. Bunu sağlamak için Bu komuşya yapılan anonslarda sanki network bir kaç AS daha ilerdeymiş gibi davranabiliriz. Bu aynı RIP de bir routerin bir hop ilerisindeki netowrkü sanki on hop ilerisinde gibi anons etmesi gibi bir durumdur. Kısacası SP-A ya yapılan anonsda networkümüzü bir AS uzaklıkta gösterirken, SP-B ye yapılan anonslarda bu değeri istediğimiz kadar arttırabiliriz. Bu yapılandırmayı route-map ile belirtip istediğimiz komşuya yapılan anonslarda out yönünde uygulayabiliriz. Örnek yapılandırma şöyle olabilir;
router bgp 300
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 description Backup ISP
neighbor 3.3.3.3 route-map TEST out
!
route-map TEST
set as-path prepend 300 300 300 300
Bu durumda SP-B RouterA tarafından anons edilen rotaları aşağıdaki gibi görecektir. Yani burayı 5 AS ileride görcektir. SP-A da ise RouterA ya giden paketlerde aynı yer 1 AS uzaklıkta görünmektedir. Yukarıda da görüldüğü gibi AS-PATH değerine 4 tane aynı AS eklenmiştir yani toplam değer belirtildiği gibi 5 AS e ulaşmıştır. Ekran çıktısını kendi yaptığım küçük bir labdan aldım bir sonraki yazıda bu labı nasıl yaptığımı da belirteceğim. Burda görüldüğü gibi SP-B bile RouterA ya SP-A üzerinden gitmektedir.
As-path prepend komutu uygulanırken kaç adet ekstradan AS eklenmesi gerektiğini hesaplamanın garanti bir yolu yoktur kimi zamanlar burda belirtildiği gibi 4 AS eklemek yeterli olmayabilir, size gelen paketlerin hangi rotayı izlediğini dünyanın farklı notlarından izlemek için http://www.bgp4.as/looking-glasses adresinde bulunan Looking Glass web siteleri aracılığı ile belirleyebilirsiniz.
Autonomous System(AS) Path Attribute:
Autonomous System(AS) Path Attribute, her BGP update mesajında bulunmalıdır. Dolayısıyla well-known mandatory bir attribute’tür. Bir route update’i bir autonomous system’den diğerine geçerken autonomous system numarası eklenerek bir sonraki EBGP komşusuna iletilir. AS Path Attribute, bir rotanın geçtiği tüm autonomous system’lerin listesidir.
Yukarıdaki şekilde görüldüğü üzere 63200 AS’sine dahil olan A router’ı 10.1.1.0 network’ünü duyurur. Bu rota 63600 AS’sinden geçerken C router’ı buna kendi AS numarasını ekler. 10.1.1.0 update’i, B router’ına ulaştığında üzerine eklenmiş iki AS numarası vardır. B router’ının bakış açısından, 10.1.1.0 network’üne erişim yolu (63600, 63200) ‘dür.
Benzer biçimde A router’ının 10.1.2.0 network’üne erişim yolu (63600, 63500) ‘dür. C router’ı ise 10.1.1.0 network’üne (63200) yolu üzerinden ve 10.1.2.0 network’üne (63500) yolu üzerinden erişebilir.
Next-Hop Attribute:
Next-Hop Attribute, her BGP update mesajında bulunmalıdır. Dolayısıyla well-known mandatory bir attribute’tür. BGP next-hop attribute’ü, bir rotaya erişmek için kullanılacak IP adresidir. EBGP için next-hop, update mesajını yollayan komşunun IP adresidir.
Yukarıdaki şekilde görüldüğü üzere A router’ı B router’ına 172.20.0.0 network’ünü 10.10.1.2 next-hop adresiyle duyurur ve B router’ı A roter’ına 172.30.0.0 network’ünü 10.10.1.1 next-hop adresiyle duyurur.
IBGP için kural, EBGP tarafından duyurulan next-hop adresin IBGP içinde taşınmasıdır. Bu yüzden B router’ı 172.20.0.0 network’ünü IBGP komşusu C router’ına 10.10.1.2 next-hop adresiyle yani A router’ının adresiyle duyurur. Böylece C router’ı için next-hop adresi 172.30.20.1 değil 10.10.1.2’dir. Bu yüzden C router’ı 10.10.1.0 network’üne nasıl erişeceğini bir IGP(Interior Gateway Protocol) veya statik rota vasıtasıyla bilmelidir. Eğer bunu bilmezse 172.20.0.0 network’üne gönderilen paketleri, next-hop adresine erişemediği için drop eder.
Alternatif olarak, B router’ı üzerinde neighbor next-hop-self komutu çalıştırılarak next-hop adresi olarak 172.30.20.1 adresini duyurması sağlanabilir.
Origin Attribute:
Origin Attribute, her BGP update mesajında bulunmalıdır. Dolayısıyla well-known mandatory bir attribute’tür. Origin attribute, bir rotanın orijin bilgisini belirtir. Origin attribute, aşağıdaki üç değerden birini alabilir:
  • IGP: Rotanın network komutu vasıtasıyla duyurulduğu anlamına gelmektedir. Bu rotalar ‘i’ harfiyle gösterilir.
  • EGP: Rotanın EGP vasıtasıyla öğrenildiğini gösterir. Bu rotalar ‘e’ ile gösterilir. EGP classful bir protokol olduğundan şu an kullanılmamaktadır.
  • Incomplete: Bir rota BGP içine redistribute edilmiş ise bu rotanın orijini incomplete olarak adlandırılır. Bu rotalar ‘?’ ile gösterilir.
Local Preference Attribute:
Local Preference Attribute, her BGP update mesajında bulunmak zorunda değildir. Dolayısıyla well-known discretionary bir attribute’tür. Bir AS içinde, AS dışına çıkmak için hangi yolun kullanılacağını belirtir. Daha yüksek local preference değerine sahip olan yol tercih edilir. Local preference değeri, bir router üzerinde tanımlanabilir ve aynı AS içindeki diğer routerlar ile paylaşılır. Local preference’ın default değeri 100’dür.
Yukarıdaki şekilde görüldüğü üzere, 63650 AS’si 172.20.0.0 network’üne erişmek için iki yönden update mesajları almaktadır. A router’ı üzerinde 172.20.0.0 network’üne erişim ile ilgili local preference değeri 300 olarak belirlenmiştir ve B router’ı üzerinde aynı network’e erişim ile ilgili local preference değeri 200 olarak belirlenmiştir. Local preference değeri 63650 AS’sinde paylaşıldığından, bu AS’den 172.20.0.0 network’ünü hedef alan tüm trafik local preference değeri daha yüksek olan A router’ı üzerinden iletilecektir.
MED(Multi-exit Discriminator) Attribute:
MED, EBGP komşularına bir AS’ye ulaşması için tercih etmeleri gereken yolu anlatır. Bir AS, kendine başka bir AS’den erişmeyi hedefleyen trafiği yönlendirmek amacıyla MED’i kullanır. Daha düşük MED değerine sahip olan yol tercih edilir. MED değeri, AS’ler arasında paylaşılabilir. MED değeri, EBGP komşularına yollanır. EBGP komşuları MED değerini kendi AS’leri içinde paylaşırlar, fakat kendi AS’leri içinde bu bilgiyi paylaştıkları routerlar bunu başka AS’ler ile paylaşmazlar. Başka AS’lere gönderilirken MED=0 yapılarak gönderilir. MED, bir AS’ye yönlenen inbound trafiği kontrol eder.
Yukarıdaki şekilde görüldüğü üzere, B router’ı için MED=200 ve C router’ı için MED=250 olarak belirlenmiştir. A router’ı B ve C routerlarından update mesajları aldığında B’yi en iyi next-hop olarak seçer, çünkü B için MED=200 olarak belirlenmiştir ve bu değer C’nin MED değerinden daha düşüktür.
Weight Attribute:
Weight Attribute, Cisco’ya özgü bir attribute’tür. Weight attribute bir router üzerinde lokal olarak tanımlanır ve diğer routerlara duyurulmaz. Bu attribute, AS’den çıkmak için tek bir router kullanıldığında ve bu router’ın birden fazla çıkışı olduğunda kullanılır. Weight değeri 0 ile 63535 arasında değişebilir. Orijini lokal router olan yollar default olarak 32768 değerini, diğerleri 0 değerini alırlar. Daha yüksek weight değerine sahip olan yol tercih edilir.
Yukarıdaki şekilde görüldüğü üzere; A router’ı B’den gelen update’ler için weight değerini 250 olarak, C’den gelen update’ler için weight değerini 200 olarak belirlemiştir. A router’ının 172.30.0.0’a erişmek için iki yolu vardır. B’den gelen update’ler için weight değeri daha yüksek olduğundan B yolu tercih edilecektir.

  maximum-paths : Bu komut ile 2 adet ısp cihazımız var ise load balancing yapabiliriz. Paket bir alttakini bir üsteki isp'yi sececektir.

router bgp 14567

  maximum-paths 2



Juniper;

set routing-options autonomous-system 65000
set protocols bgp group AS type external
set protocols bgp group AS export BGP_ANONS
set protocols bgp group AS peer-as 65051
set protocols bgp group AS neighbor 172.19.0.2

set policy-options prefix-list PROVUS_BGP 172.19.27.0/24(your network)
set policy-options policy-statement BGP_ANONS term PROVUS from prefix-list PROVUS_BGP
set policy-options policy-statement BGP_ANONS term PROVUS then accept


Remove Private AS


Private ASN are 64512 - 65534
Public ASN are 1 - 64511

Private as'ler aynı private ip'ler gibi ısp icerisinde anons edilmemelidir. eğer edilirse su komutla anons edilmesi outgoing yönünde kaldırabiliriz.

router bgp 3
neighbor 1.1.1.6 remove-private-as







R2:

interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet1/0
 ip address 1.1.1.1 255.255.255.252
!
router bgp 65002
 bgp log-neighbor-changes
 network 2.2.2.2 mask 255.255.255.255
 neighbor 1.1.1.2 remote-as 3

R3:

interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet1/0
 ip address 1.1.1.2 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.5 255.255.255.252
!
router bgp 3
 bgp log-neighbor-changes
 network 3.3.3.3 mask 255.255.255.255
 neighbor 1.1.1.1 remote-as 65002
 neighbor 1.1.1.6 remote-as 4
 neighbor 1.1.1.6 remove-private-as


R4:

interface Loopback0
 ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
 ip address 1.1.1.9 255.255.255.252
!
interface FastEthernet1/1
 ip address 1.1.1.6 255.255.255.252
!
router bgp 4
 bgp log-neighbor-changes
 network 4.4.4.4 mask 255.255.255.255
 neighbor 1.1.1.5 remote-as 3
 neighbor 1.1.1.10 remote-as 5

R1:

interface Loopback0
 ip address 5.5.5.5 255.255.255.255
!
interface FastEthernet0/0
 ip address 1.1.1.10 255.255.255.252
!
router bgp 5
 bgp log-neighbor-changes
 network 5.5.5.5 mask 255.255.255.255
 neighbor 1.1.1.9 remote-as 4

Hiç yorum yok:

Yorum Gönder