본문 바로가기
네트워크

BGP #2(Next Hop,Split Horizon)

by CBROJIN 2025. 4. 10.

[학습 목표]

1) BGP 넥스트홉(Next Hop)

2) BGP 스플릿 호라이즌(Split Horizon)


1) BGP 넥스트홉(Next Hop) / next-hop-self , DMZ구간 IGP에 포함

✅ 기본 개념

  • eBGP에서는 직접 연결된 이웃 라우터의 IP 주소가 Next Hop이 된다.
  • iBGP에서는 Next Hop이 바뀌지 않는다.

 

R1이 R2에게 10.10.12.0/24 네트워크를 광고하면,
R2는 R1의 인터페이스 IP 10.10.12.0/24 를 Next Hop으로 설정해서 R3에게 그대로 전달한다.
즉, R3은 Next Hop으로 10.10.12.1을 모르기 때문에 못간다.

❗R3이 10.10.12.1로 가는 경로를 알고 있어야 한다.
그렇지 않으면 라우팅은 실패하게 된다.

R2,R3,R4 BGP 테이블

# R2가 R1으로 부터 받은 Next hop을 R3,R4에게 그대로 전달한 모습이다.(위 사진)

BGP 테이블에서 최적경로를 알려주는 ">" 모양이 R3,4에는 없다.

R4 -> R1 핑 확인

# 10.10.10.0 경로가 R4 BGP 테이블엔 있지만 RIB에는 설치 안되있다. 10.10.10.0 경로를 모르는 R4는 R1으로의 핑이 실패한다.(위 사진)

BGP 설정(Next Hop)
기본 설정
R1(config)#int lo0
R1(config-if)#ip add 10.10.10.10 255.255.255.0
R1(config)#int e0/0
R1(config-if)#ip add 10.10.12.1 255.255.255.0
R1(config-if)#no shut
R1(config)#router bgp 1
R1(config-router)#bgp router-id 10.10.10.10
R1(config-router)#neighbor 10.10.12.2 remote-as 2
R1(config-router)#network 10.10.10.0 mask 255.255.255.0

기본 설정
R2(config)#int lo0
R2(config-if)#ip add 20.20.20.20 255.255.255.0
R2(config-if)#int e0/0
R2(config-if)#ip add 10.10.12.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int e0/1
R2(config-if)#ip add 20.20.23.2 255.255.255.0
R2(config-if)#no shut
R2(config)#router ospf 1
R2(config-router)#router-id 20.20.20.20
R2(config-router)#network 20.20.23.2 0.0.0.0 area 0
R2(config-router)#network 20.20.20.20 0.0.0.0 area 0
R2(config-router)#passive-interface e0/0
R2(config)#int e0/1
R2(config-if-range)#ip ospf network point-to-point
R2(config)#router bgp 2
R2(config-router)#bgp router-id 20.20.20.20
R2(config-router)#neighbor 10.10.12.1 remote-as 1
R2(config-router)#network 20.20.20.0 mask 255.255.255.0
R2(config-router)#neighbor 30.30.30.30 remote-as 2
R2(config-router)#neighbor 30.30.30.30 update-source lo0
R2(config-router)#neighbor 40.40.40.40 remote-as 2 
R2(config-router)#neighbor 40.40.40.40 update-source lo0

next-hop-self
R2(config)#router bgp 2
R2(config-router)#neighbor 30.30.30.30 next-hop-self
R2(config-router)#neighbor 40.40.40.40 next-hop-self

DMZ IGP에 포함
R2(config)#router bgp 2
R2(config-router)#no neighbor 30.30.30.30 next-hop-self
R2(config-router)#no neighbor 40.40.40.40 next-hop-self

R2(config)#router ospf 1
R2(config-router)#network 10.10.12.2 0.0.0.0 area 0  
기본 설정
R3(config)#int lo0
R3(config-if)#ip add 30.30.30.30 255.255.255.0
R3(config-if)#int e0/1
R3(config-if)#ip add 20.20.23.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int e0/2
R3(config-if)#ip add 30.30.34.3 255.255.255.0
R3(config-if)#no shut
R3(config)#router ospf 1
R3(config-router)#router-id 30.30.30.30
R3(config-router)#network 20.20.23.3 0.0.0.0 area 0
R3(config-router)#network 30.30.34.3 0.0.0.0 area 0
R3(config-router)#network 30.30.30.30 0.0.0.0 area 0
R3(config)#int range e0/1-2
R3(config-if-range)#ip ospf network point-to-point
R3(config)#router bgp 2
R3(config-router)#bgp router-id 30.30.30.30
R3(config-router)#neighbor 20.20.20.20 remote-as 2
R3(config-router)#neighbor 20.20.20.20 update-source lo0
R3(config-router)#neighbor 40.40.40.40 remote-as 2
R3(config-router)#neighbor 40.40.40.40 update-source lo0
R3(config-router)#network 30.30.30.0 mask 255.255.255.0
기본 설정
R4(config-if)#int lo0
R4(config-if)#ip add 40.40.40.40 255.255.255.0
R4(config-if)#int e0/2
R4(config-if)#ip add 30.30.34.4 255.255.255.0
R4(config-if)#no shut
R4(config)#router ospf 1
R4(config-router)#router-id 40.40.40.40
R4(config-router)#network 30.30.34.4 0.0.0.0 area 0
R4(config-router)#network 40.40.40.40 0.0.0.0 area 0
R4(config-router)#int e0/2
R4(config-if)#ip ospf network point-to-point
R4(config)#router bgp 2

R4(config-router)#bgp router-id 40.40.40.40
R4(config-router)#neighbor 30.30.30.30 remote-as 2
R4(config-router)#neighbor 30.30.30.30 update-source lo0 
R4(config-router)#neighbor 20.20.20.20 remote-as 2
R4(config-router)#neighbor 20.20.20.20 update-source lo0
R4(config-router)#network 40.40.40.0 mask 255.255.255.0

🔎 해결방법 1 : next-hop-self 옵션

광고하는 eBGP 경로의 Next Hop을 R3,R4에게 나 자신(R2)으로 설정하는 명령

 

R2(config)#router bgp 2
R2(config-router)#neighbor 30.30.30.30 next-hop-self
R2(config-router)#neighbor 40.40.40.40 next-hop-self

next-hop-self 설정 후 R3,4 BGP 테이블

# R2에서 next-hop-self 설정 후 R3,4 Next Hop이 바뀐 모습이다.(위 사진) 

최적경로 ">" 표시가 생겼고, Next Hop이 R2 lo0 20.20.20.20으로 바꼈다.

 

설정 후 R4 -> R1 핑 확인

 

# R2는 AS1 소속인 R1에 대한 경로를 가지고 있기 때문에, R3,4가 R2까지 가면 R1과 통신이 가능하다. 

 

🔎 해결방법 2 : 인터페이스 네트워크(DMZ 구간)를 IGP(OSPF 등)에 포함

R1-R2 간의 인터페이스(=DMZ 구간)를 IGP(OSPF 등)에 포함시킴

 

R2(config)#router ospf 1
R2(config-router)#network 10.10.12.2 0.0.0.0 area 0 

설정 후 R3,4 BGP 테이블

# next-hop-self 옵션과 다르게 IGP(OSPF)로 외부망 인터페이스를 광고 했기 때문에 Next Hop이 10.10.12.1인 모습이다.

(위 사진)

 

# AS 2 영역은 라우터들이 IGP(OSPF)로 이미 네이버를 맺고있다.

R1 <--> R2 구간에서 R2 인터페이스를 IGP에 포함(광고) 함으로써 R3,4도 외부망(AS 1)로 가는 경로를 배우게 된다.

 


2) BGP 스플릿 호라이즌(Split Horizon) / Full-Mesh , RR

✅ 기본개념

  • 스플릿 호라이즌은 라우팅 루프를 방지하기 위해 iBGP로 부터 받은 광고는 다른 iBGP로 광고하지 못하는 룰이다.

 # R3는 R2로부터 eBGP에 대한 정보를 받지만 R4는 R3가 R2로 부터 iBGP로 정보를 받았기 때문에,

eBGP에 대한 광고를 받지 못한다.

R3(좌),R4(우) BGP 테이블

# 10.10.10.10 네트워크에 대한 광고를 R3는 받았지만, R4는 받지 못했다.(위 사진)

BGP 설정(Split Horizon)
기본 설정
R1(config)#int lo0
R1(config-if)#ip add 10.10.10.10 255.255.255.0
R1(config)#int e0/0
R1(config-if)#ip add 10.10.12.1 255.255.255.0
R1(config-if)#no shut
R1(config)#router bgp 1
R1(config-router)#bgp router-id 10.10.10.10
R1(config-router)#neighbor 10.10.12.2 remote-as 2
R1(config-router)#network 10.10.10.0 mask 255.255.255.0

기본 설정
R2(config)#int lo0
R2(config-if)#ip add 20.20.20.20 255.255.255.0
R2(config-if)#int e0/0
R2(config-if)#ip add 10.10.12.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int e0/1
R2(config-if)#ip add 20.20.23.2 255.255.255.0
R2(config-if)#no shut
R2(config)#router ospf 1
R2(config-router)#router-id 20.20.20.20
R2(config-router)#network 20.20.23.2 0.0.0.0 area 0
R2(config-router)#network 20.20.20.20 0.0.0.0 area 0
R2(config-router)#passive-interface e0/0
R2(config)#int e0/1
R2(config-if-range)#ip ospf network point-to-point
R2(config)#router bgp 2
R2(config-router)#bgp router-id 20.20.20.20
R2(config-router)#neighbor 10.10.12.1 remote-as 1
R2(config-router)#network 20.20.20.0 mask 255.255.255.0
R2(config-router)#neighbor 30.30.30.30 remote-as 2
R2(config-router)#neighbor 30.30.30.30 update-source lo0

풀메쉬 설정
R2(config)#router bgp 2
R2(config-router)#neighbor 40.40.40.40 remote-as 2
R2(config-router)#neighbor 40.40.40.40 update-source lo0

RR 설정
R2(config)#router bgp 2
R2(config-router)#no neighbor 40.40.40.40 remote-as 2
R2(config-router)#no neighbor 40.40.40.40 update-source lo0

기본 설정
R3(config)#int lo0
R3(config-if)#ip add 30.30.30.30 255.255.255.0
R3(config-if)#int e0/1
R3(config-if)#ip add 20.20.23.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int e0/2
R3(config-if)#ip add 30.30.34.3 255.255.255.0
R3(config-if)#no shut
R3(config)#router ospf 1
R3(config-router)#router-id 30.30.30.30
R3(config-router)#network 20.20.23.3 0.0.0.0 area 0
R3(config-router)#network 30.30.34.3 0.0.0.0 area 0
R3(config-router)#network 30.30.30.30 0.0.0.0 area 0
R3(config)#int range e0/1-2
R3(config-if-range)#ip ospf network point-to-point
R3(config)#router bgp 2
R3(config-router)#bgp router-id 30.30.30.30
R3(config-router)#neighbor 20.20.20.20 remote-as 2
R3(config-router)#neighbor 20.20.20.20 update-source lo0
R3(config-router)#neighbor 40.40.40.40 remote-as 2
R3(config-router)#neighbor 40.40.40.40 update-source lo0
R3(config-router)#network 30.30.30.0 mask 255.255.255.0

RR 설정
R3(config)#router bgp 2
R3(config-router)#neighbor 20.20.20.20 route-reflector-client
R3(config-router)#neighbor 40.40.40.40 route-reflector-client

기본 설정
R4(config-if)#int lo0
R4(config-if)#ip add 40.40.40.40 255.255.255.0
R4(config-if)#int e0/2
R4(config-if)#ip add 30.30.34.4 255.255.255.0
R4(config-if)#no shut
R4(config)#router ospf 1
R4(config-router)#router-id 40.40.40.40
R4(config-router)#network 30.30.34.4 0.0.0.0 area 0
R4(config-router)#network 40.40.40.40 0.0.0.0 area 0
R4(config-router)#int e0/2
R4(config-if)#ip ospf network point-to-point
R4(config)#router bgp 2

R4(config-router)#bgp router-id 40.40.40.40
R4(config-router)#neighbor 30.30.30.30 remote-as 2
R4(config-router)#neighbor 30.30.30.30 update-source lo0 
R4(config-router)#network 40.40.40.0 mask 255.255.255.0

풀 메쉬 설정
R4(config)#router bgp 2
R4(config-router)#neighbor 20.20.20.20 remote-as 2
R4(config-router)#neighbor 20.20.20.20 update-source lo0

RR 설정
R4(config-router)#no neighbor 20.20.20.20 remote-as 2
R4(config-router)#no neighbor 20.20.20.20 update-source lo0

🔎 해결방법 1 : Full-Mesh 설정

R2(config)#router bgp 2
R2(config-router)#neighbor 40.40.40.40 remote-as 2
R2(config-router)#neighbor 40.40.40.40 update-source lo0

# 위와 같이 R2,R3,R4가 각각 iBGP 라우터 모두와 neighbor 관계를 맺기 때문에,

그럼 R2가 R3,R4에게 eBGP에 대한 정보를 모두 전달하기 때문에 R4도 eBGP에 대한 경로가 생긴다.(아래 사진)

Full-Mesh 설정 후 R4 BGP 테이블

 

Full-Mesh 장점

항목 설명
구조가 단순하고 직관적 복잡한 RR이나 Confederation 없이도 경로 전파 가능
경로 왜곡 없음 중간 라우터 없이 직접 연결이므로, 반사/재작성 등에 의한 경로 왜곡이 없다
디버깅/트래픽 분석 쉬움 투명한 경로 정보 제공 → 경로 추적 및 문제 분석이 쉬움

Full-Mesh 단점

항목 설명
확장성 한계 라우터 수가 많아질수록 BGP 세션 수가 기하급수적으로 증가
운영 복잡도 증가 라우터 수가 10대만 넘어가도 관리가 매우 복잡해짐
CPU, 메모리 사용량 증가 세션 수 많아지면 BGP Keepalive, Update 처리 부하 증가
HA/Failover 설계 어려움 구조가 단순한 만큼 유연성 부족 (예: 특정 피어 죽으면 전파 차단될 수 있음)

 

🔎 해결방법 2 : RR(Route Reflector) 설정

RR (Route Reflector) : iBGP 경로를 대신 반사(전달)해주는 중앙 역할의 라우터

RR Client : RR에게 경로를 받거나 전달하는 iBGP 라우터

Non-Client : 일반 iBGP 라우터 (RR의 클라이언트가 아님)

경로 수신자경로 반사 대상
RR ← eBGP RR-Client, Non-Client 모두에게 반사
RR ← RR-Client RR-Client & Non-Client 모두에게 반사
RR ← Non-Client RR-Client에게만 반사 (Non-Client 간은 ❌ 공유 안 됨)

 

R4 BGP 경로

R3(config)#router bgp 2
R3(config-router)#neighbor 20.20.20.20 route-reflector-client
R3(config-router)#neighbor 40.40.40.40 route-reflector-client

# 위 설정 후 R2,R4가 iBGP 네이버 관계가 아니여도 R3을 통해 R2 정보를 받기 때문에 Full-Mesh 구성을 안해도,

10.10.10.10 경로를 배울수 있다.

 

RR 장점

항목 설명
Full-Mesh 불필요 RR-Client끼리는 iBGP 연결 안 해도 됨
확장성 높음 대규모 네트워크에 적합
설정 간단 RR 하나만 설정하면 클라이언트는 단순 구성 가능

 

RR 단점

항목 설명
RR 장애 시 문제 RR 이중화 (HA) 필요
비최적 경로 가능 RR이 전체 토폴로지를 몰라서 최적 경로 못 고를 수도 있음
디버깅이 어렵다 경로 반사 구조는 경로 흐름을 직관적으로 파악하기 어려움

 

Full-Mesh vs RR

항목 Full-Mesh Route Reflector
구조 복잡도 낮음 (작은 규모 한정) 중간
확장성 ❌ 제한적 ✅ 좋음
경로 투명성 ✅ 최고 보통
실무 적용 소규모 기업, 시험용 대부분 환경
정책 유연성 제한적 중간

 

 

Cluster ID 와 Originator ID

용어 설명
Cluster ID RR가 속한 클러스터(논리적 그룹)를 식별하는 고유한 ID
Originator ID iBGP 경로를 최초로 생성한 라우터의 Router-ID

✅ Originator ID 정의

  • RR-Client가 외부에서 받은 BGP 경로를 iBGP RR에게 전달할 때, RR은 이 경로를 다른 Client 또는 Non-Client에게 반사(reflect)함. 이때 RR은 해당 경로가 어디에서 시작되었는지 표시하기 위해 경로에 Originator ID 필드를 추가함.

✅ 목적

  • 라우팅 루프 방지
  • RR이 받은 경로를 다시 원래 경로 생성자(Originator)에게 반사하지 않기 위해 사용

🔎 예시

R1 ←eBGP→ R2(Client) ←iBGP→ R3(RR) ←iBGP→ R4(Client)

 

  • R2가 R1에서 받은 경로를 R3에게 전달
  • R3는 이 경로를 R4에게 반사함
  • 경로에는 Originator ID = R2 Router-ID가 기록됨
  • R2는 이 경로를 다시 받았을 때, 자기 Originator ID이므로 무시함 → 루프 방지됨

 

✅ Cluster ID 정의

  • Route Reflector 클러스터를 구분하기 위한 ID
  • RR은 자신이 속한 클러스터의 ID를 경로에 붙임
  • 하나의 클러스터 ID를 공유하는 RR끼리는 같은 클러스터에 속한 것으로 간주

🔎 예시

  R1(RR1)   R2(RR2)
        ↙         ↘
  R3(Client)   R4(Client)
        ↖         ↗

            (iBGP)

  • RR1, RR2 가 서로 피어링 되어 있고, R1과 R2가 각각 RR이고, 둘 다 같은 클러스터 ID 1.1.1.1로 설정하면
  • 경로 반사 시, RR1이 보낸 경로를 RR2가 같은 클러스터 ID를 보고 무시함 → 경로 루프 방지

'네트워크' 카테고리의 다른 글

BGP #3(weight,local preference,MED)  (0) 2025.04.12
BGP #1(iBGP,eBGP)  (0) 2025.04.07
OSPF #4(Virtual-link,Demand circuit)  (0) 2025.04.05
OSPF #3(Summarization,Authentication)  (0) 2025.04.02
OPSF #2(LSA,Stub Area)  (0) 2025.03.30