본문 바로가기
Network/Network기초

42.BGP 정책

by JINJINC 2023. 3. 13.
728x90
반응형

◇ BGP 속성의 분류 ◇

동일한 IGP가 동작하는 모든 라우터들은 해당 IGP의 메트릭을 모두 알고 있어야 한다.

그러나, BGP가 사용하는 다양한 종류의 메트릭(속성)은 모든 BGP 라우터가 반드시 다 알고 구현해야하는 것은 아니다.

또한 BGP는 최적 경로가 가려질 때까지 각 속성을 개별적으로 비교해 내려간다.

 

  • Well-Know : BGP Router가 반드시 알고 있어야 하는 속성
    • mandatory (AS-path, next-hop, origin code) BGP Router에 반드시 표시되어야 하는 속성
    • discretionary (local-preference, atomic, aggregate(as-set)) BGP Router에 표시되어도 되고
      표시 안되도 되는 속성
  •  Optional : BGP Router가 알아도 되고 몰라도 되는 속성
    • transitive(aggregator, MED, community) 모르는 BGP 속성이 들어오면 나의 neighbor에게 알려준다
    • non-transitive(originate-ID, cluster-ID) 모르는 BGP 속성이 들어오면 나의 neighbor에게 알려주지 않는다

 

■ BGP 속성(BGP의 정책)

IGP의 메트릭에 해당하는 것을 BGP에서는 속성(attribute)라고 한다.

BGP는 looping을 방지 하기 위해 로드분산을 하지 않는다.

따라서 다음의 Attribute 확인 순서로 최적경로를 선출한다.

▶ 특정 DMZ 경계 라우터에서, 하나의 네트워크 주소를 여러 곳에서 배운경우 BGP 속성 순위대로 비교해 나간다.
    속성값이 같거나 또는 한곳이 없는 경우는 다음 속성 을 비교한다.
    비교 대상 속성이 전부 존재하고, 비교 가능한 경우 최적 경로만 iBGP 네이버에 전달한다.
   (여러 DMZ 경계 라우터에서, 네트워크 주소를 받는 경우는 전 부 iBGP 네이버에 전달한다.)

 

 

■ 입력 경로 조정

BGP 네트워크의 입력 경로 조정을 위해서는 MED 값 조정, AS 경로 추가, 스프레서 맵 사용, 조건부 광고 등의 방법을 사용한다. BGP 네트워크는 속도 등을 우선시하는 IGP와 달리 기본적으로는 성능 등이 고려되지 않고 라우팅 경로가 결정된다.

<ospf설정>

<R2>
router ospf 1
	router-id 1.1.2.2
	network 1.1.2.2 0.0.0.0 area 0
	network 1.1.12.2 0.0.0.0 area 0
	network 1.1.23.2 0.0.0.0 area 0
	passive-interface s0/0.12
int lo0
	ip ospf network point-to-point
    
<R3>
router ospf 1
	router-id 1.1.3.3
	network 1.1.3.3 0.0.0.0 area 0
	network 1.1.23.3 0.0.0.0 area 0
	network 1.1.34.3 0.0.0.0 area 0
int lo0
	ip ospf network point-to-point
    
<R4>
router ospf 1
	router-id 1.1.4.4
	network 1.1.4.4 0.0.0.0 area 0
	network 1.1.34.4 0.0.0.0 area 0
int lo0
	ip ospf network point-to-point

<bgp 설정>

<R1>
router bgp 1
bgp router-id 1.1.1.1
neighbor 1.1.12.2 remote-as 2
neighbor 1.1.14.4 remote-as 2
network 1.1.1.0 mask 255.255.255.0
<R2>
router bgp 2
bgp router-id 1.1.2.2
neighbor 1.1.12.1 remote-as 1
neighbor 1.1.3.3 remote-as 2
neighbor 1.1.3.3 update-source loopback 0
network 1.1.2.0 mask 255.255.255.0
<R4>
router bgp 2
bgp router-id 1.1.4.4
neighbor 1.1.14.1 remote-as 1
neighbor 1.1.3.3 remote-as 2
neighbor 1.1.3.3 update-source loopback 0
neighbor 1.1.3.3 next-hop-self
network 1.1.4.0 mask 255.255.255.

※ peer group

peer group이란 동일한 출력 정책이 적용되는 BGP peer를 하나의 그룹으로 묶어서 설 정하는 것을 말한다.

◇ BGP peer group 원칙 ◇

  • 원칙 1. peer group의 멤버들은 route-map, filter-list, distribute-list 등 모두 동일한 출력 정책을 가지고 있어야 한다. 디폴트 루트를 생성시키는 default-originate 명령어는 서로 달라도 된다.
  • 원칙 2. peers은 모두 iBGP peer 이거나, eBGP peer로 구성되어야 한다.(★)

eBGP peer의 경우 멤버간 서로 다른 AS 번호를 가져도 된다.

 

<R3에서 peer group 설정>

router bgp 2
bgp router-id 1.1.3.3
network 1.1.3.0 mask 255.255.255.0
neighbor R2R4 peer-group
neighbor R2R4 remote-as 2
neighbor R2R4 update-source loopback 0
neighbor R2R4 route-reflector-client
neighbor 1.1.2.2 peer-group R2R4
neighbor 1.1.4.4 peer-group R2R4
R3#show ip bgp 1.1.1.0
Advertised to update-groups:
1
1, (Received from a RR-client)
   1.1.4.4 (metric 65) from 1.1.4.4 (1.1.4.4)
     Origin IGP, metric 0, localpref 100, valid, internal, best
1, (Received from a RR-client)
    1.1.12.1 (metric 128) from 1.1.2.2 (1.1.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal

▶ MED를 이용한 입력 경로 조정

○ MED(Multi-Exit Discriminator) : 나가는 길이 여러개 인 경우

기본적으로 서로 다른 AS에서 광고받은 네트워크에 대해서는 MED 값을 비교하지 않는다.

즉, 같은 AS의 여러 경로에서 네트워크 주소를 받는 경우에 MED 값을 비교한다.

 

Route의 MED Attribute는 다른 AS로는 전달되지 않는다.(R1에서 Route에 대한 MED를 비교하며, R1은 다른 AS로 Route를 Advertise할 때 MED Attribute를 전달하지 않는다 

R1#show ip route
C 1.1.1.0 is directly connected, Loopback0
B 1.1.2.0 [20/100] via 1.1.12.2, 02:06:35
B 1.1.3.0 [20/100] via 1.1.12.2, 02:06:35
B 1.1.4.0 [20/100] via 1.1.12.2, 02:06:35
C 1.1.12.0 is directly connected, Serial0/0.12
C 1.1.14.0 is directly connected, Serial0/0.14
<R2>
ip as-path access-list 1 permit ^$
route-map INGRESS
match as-path 1
set metric 100
router bgp 2
neighbor 1.1.12.1 route-map INGRESS out
-----------------------------------------------------------
clear ip bgp * soft

<R4>
ip prefix-list AS2-NETWORK permit 1.1.2.0/24
ip prefix-list AS2-NETWORK permit 1.1.3.0/24
ip prefix-list AS2-NETWORK permit 1.1.4.0/24
route-map INGRESS
match ip address prefix-list AS2-NETWORK
set metric 200
router bgp 2
neighbor 1.1.14.1 route-map INGRESS out
-----------------------------------------------------------
clear ip bgp * soft
R1#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*> 1.1.2.0/24 1.1.12.2 100 0 2 i
* 1.1.14.4 200 0 2 i
*> 1.1.3.0/24 1.1.12.2 100 0 2 i
* 1.1.14.4 200 0 2 i
*> 1.1.4.0/24 1.1.12.2 100 0 2 i
* 1.1.14.4 200 0 2 i

 

▶ Origin 타입을 이용한 입력 경로 조정

○ network주소가 어떤 방식으로 BGP에 포함되었는가 ?

.  IGP : 최초 라우팅 테이블에 IGP를 통해 배운 경로를 BGP에 network명령어로 포함되어 => 배움

. EGP : 최초 BGP 전신인 EGP프로토콜에 포함되어 => 배움

. INCOMPLETE : 최초 BGP에 재분배를 통해 포함되어 => 배움 "IGP(i ) > EGP > INCOMPLETE(?)"

 

ip prefix-list AS2-NETWORK permit 1.1.2.0/24
ip prefix-list AS2-NETWORK permit 1.1.3.0/24
ip prefix-list AS2-NETWORK permit 1.1.4.0/24
route-map CHANGE-ORIGIN-TYPE
match ip address prefix-list AS2-NETWORK
set origin incomplete
router bgp 2
neighbor 1.1.14.1 route-map CHANGE-ORIGIN-TYPE out
-----------------------------------------------------------
clear ip bgp * soft

R1# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*> 1.1.2.0/24 1.1.12.2 0 0 2 i
* 1.1.14.4 0 2 ?
*> 1.1.3.0/24 1.1.12.2 0 2 i
* 1.1.14.4 0 2 ?
*> 1.1.4.0/24 1.1.12.2 0 2 i
* 1.1.14.4 0 0 2 ?

▶ AS 경로 추가를 이용한 입력 경로 조정

○ AS-path prepending 방법은 기존의 AS 경로 리스트에 임의의 AS 경로값을 추가하여 AS 경로 길이를 증가시킴으로써, BGP 경로 결정에 영향을 미치는 것을 말한다.

 

 

<R4>
ip prefix-list AS2-NETWORK permit 1.1.2.0/24
ip prefix-list AS2-NETWORK permit 1.1.3.0/24
ip prefix-list AS2-NETWORK permit 1.1.4.0/24
route-map MORE-AS
match ip address prefix-list AS2-NETWORK
set as-path prepend 2 2
router bgp 2
neighbor 1.1.14.1 route-map MORE-AS out
-----------------------------------------------------------
clear ip bgp * soft
R1# show ip route
C 1.1.1.0 is directly connected, Loopback0
B 1.1.2.0 [20/0] via 1.1.12.2, 00:01:49
B 1.1.3.0 [20/0] via 1.1.12.2, 00:01:49
B 1.1.4.0 [20/0] via 1.1.12.2, 00:01:49
C 1.1.12.0 is directly connected, Serial0/0.12
C 1.1.14.0 is directly connected, Serial0/0.14
R1# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*> 1.1.2.0/24 1.1.12.2 0 0 2 i
* 1.1.14.4 0 2 2 2 i
*> 1.1.3.0/24 1.1.12.2 0 2 i
* 1.1.14.4 0 2 2 2 i
*> 1.1.4.0/24 1.1.12.2 0 2 i
* 1.1.14.4 0 0 2 2 2 i

■ 출력 경로 조정

-  BGP 출력 경로 조정을 위해서는 주로 로컬 프레퍼런스 와 웨이드 값을 조정한다.

 

▶ Local Preference

  기본값이 달라지는 MED와는 달리 로컬 프레퍼런스는 기본값이 항상 100 이므로 한쪽 라우터에서만 상대적으로 높거나    낮게 조정하면 된다. ( 높은 것이 우선 )

<R2>
ip prefix-list R1 permit 1.1.1.0/24
route-map EGRESS
match ip address prefix-list R1
set local-preference 200
router bgp 2
neighbor 1.1.12.1 route-map EGRESS in
-----------------------------------------------------------
clear ip bgp * soft
R2# show ip bgp 1.1.1.0
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 1.1.12.1 0 200 0 1 i
*> 1.1.2.0/24 0.0.0.0 0 32768 i
r>i 1.1.3.0/24 1.1.3.3 0 100 0 i
r>i 1.1.4.0/24 1.1.4.4 0 100 0 i

R3#show ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.0/24 1.1.12.1 0 200 0 1 i
r>i1.1.2.0/24 1.1.2.2 0 100 0 i
*> 1.1.3.0/24 0.0.0.0 0 32768 i
r>i1.1.4.0/24 1.1.4.4 0 100 0 i

R4# show ip bgp 1.1.1.0
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.0/24 1.1.12.1 0 200 0 1 i
* 1.1.14.1 0 0 1 i
r>i1.1.2.0/24 1.1.2.2 0 100 0 i
r>i1.1.3.0/24 1.1.3.3 0 100 0 i
*> 1.1.4.0/24 0.0.0.0 0 32768 i

 

▶ Weight를 이용한 출력 경로 조정 AS 2의 R2,R3 에서는 목적지가 AS 1의 1.1.1.0 네트워크인 패킷을 R2-R1 링크로 라우 팅시키고, R4 에서는 R4-R1 경로로 라우팅 시켜보자.

 

<R4>
ip prefix-list R1 permit 1.1.1.0/24
route-map EGRESS
match ip address prefix-list R1
set local-preference 50
set weight 1000
router bgp 2
neighbor 1.1.14.1 route-map EGRESS in
----------------------------------------------------------
clear ip bgp * soft
R2# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 1.1.12.1 0 200 0 1 i
*> 1.1.2.0/24 0.0.0.0 0 32768 i
r>i1.1.3.0/24 1.1.3.3 0 100 0 i
r>i1.1.4.0/24 1.1.4.4 0 100 0 i

R3# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.0/24 1.1.12.1 0 200 0 1 i
r>i1.1.2.0/24 1.1.2.2 0 100 0 i
*> 1.1.3.0/24 0.0.0.0 0 32768 i
r>i1.1.4.0/24 1.1.4.4 0 100 0 i

R4# show ip bgp
Network Next Hop Metric LocPrf Weight Path
* i1.1.1.0/24 1.1.12.1 0 200 0 1 i
*> 1.1.14.1 0 50 1000 1 i
r>i1.1.2.0/24 1.1.2.2 0 100 0 i
r>i1.1.3.0/24 1.1.3.3 0 100 0 i
*> 1.1.4.0/24 0.0.0.0 0 32768 i
728x90
반응형

'Network > Network기초' 카테고리의 다른 글

41.BGP - BGP 동기화 법칙 해결  (0) 2023.03.13
40.BGP- 넥스트 홉 해결  (0) 2023.03.13
39.BGP - Split horizon 법칙 해결  (0) 2023.03.13

댓글