본문 바로가기
network/ccie-bgp

Configuring Basic BGP

Configuring Basic BGP

# 네이버 연결 
- 아래와 같이 프로세스를 생성 하며 한 라우터당 1개의 as로 bgp프로세스를 활 성화 할 수 있다.
router(config)#router bgp as-number

# 네이버 연결 지정 및 주석
router(config-router)# neighbor ip-address remote-as as-number
router(config-router)#neighbor ip-address description neighbor description

# 네이버 일시 정지 
- no 설정을 하게 되면 모든 정책이 지워지기 때문에 일시적으로 끊을때는 shutdown을 할 수 있다.
router(config-router)# neighbor ip-address shutdown

# holdtime 설정 
- 아래와 같이 설정 가능 하다.
router(config-router)# timers bgp keepalive holdtime

# md5 인증
- 자동으로 md5 인증이 되기 때문에 뒤에 암호키만 입력 하면 된다.
router(config-router)# neighbor ip-address password string

# auto aummary 
- 기본적으로 disable 되어 있음
router(config-router)#auto-summary
-수동으로 RIB에 있으면 수동 summary 가능 하다
router(config-router)#  network major-network-number

# 성질 변경
- 아래 처럼 route-map 을 이용하여 광고 되는 성질을 변경 할 수 있다.
router(config-router)#network major-network-number route-map route-map-name

 

# R2와 R1이 네이버를 연결 하기 위해 R1에 인터페이스를 shutdown상태로 진행 한다.
R1(config)#inte e 1/0
R1(config-if)#shutdown

# R1의 bgp as123으로 프로세스 활성화 후 10.10.12.2 의 R2의 라우터 아이피로 456 AS번호로 네이버를 연결 한다.
# 추가적으로 주석 설정을 진행 한다.
R1(config)#router bgp 123
 R1(config-router)#r neighbor 10.10.12.2 remote-as 456
 R1(config-router )#r neighbor 10.10.12.2 description R2-BGP

# show ip bgp summary 설정시 자신의 인터페이스가 활성화 되어 있지 않기 때문에 idle 상태가 된다.
R1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.10.12.2      4   456       0       0        0    0    0 never    Idle

# 인터페이스 활성화 후 active상태가 되어 R1은 준비가 되었음을 알게 된다.
R1(config)#inte e 1/0
R1(config-if)#no sh
R1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.10.12.2      4   456       0       0        0    0    0 never    Active

# R2에서 BGP네이버  설정을 진행 한다 이때 R1의 bgp정보를 입력 한다.
R2(config)#router bgp 456
R2(config-router)#r neighbor 10.10.12.1remote-as-123
 R2(config-router )#r neighbor 10.10.12.1 description R2-BGP

# R1에서 BGP 네이버 성립시 아래와같이 확인이 가능하다.PfxRcd가 0인 이유는 아직 네트워크 정보를 받지 못해 0으로 되어 있다.
R1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.10.12.2      4   456       5       5        1    0    0 00:01:53        0              

#해당 구간 패킷 확인시 TCP 179번 포트로 세션을 연결후 open message로 네이버 연결 후 주기적인 keepalive 를 확인 할 수 있다.

 

 

 

  


# OPEN message 를 확인하면 페킷의 타입과 버전 hold time 등이 있는 것을 확인 할 수 있다.

# 또한 keepl alive 는 push,ack 으로 그자체가 ack이기 때문에 해당 메세지에 대한 ack은 없다.

 

 

 

 

 

# bgp네이버 정보를 확인 하면 기본 적으로는 hold time 180 초 60 초로 확인 할 수 있다.

R1(config-router)#do show ip bgp nei             
BGP neighbor is 10.10.12.2,  remote AS 456, external link
 Description: R2-BGP
  BGP version 4, remote router ID 2.2.2.2
  BGP state = Established, up for 00:00:06
  Last read 00:00:05, last write 00:00:06, hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
  Message statistics:

# BGP 네이버 연결을 잠시 끊고 keepalive 와 holdtime을 조절 한다. 
R1(config-router)#neighbor 10.10.12.2 shutdown
R1(config-router)#timers bgp 30 90             
R1(config-router)#no neighbor 10.10.12.2 shutdown

# R2와 R1의 keepalive,holdtime 이 변경 된것을 알 수 있다.
 R2(config-router)#do show ip bgp ne                     
BGP neighbor is 10.10.12.1,  remote AS 123, external link
 Description: R1-BGP
  BGP version 4, remote router ID 1.1.1.1
  BGP state = Established, up for 00:00:09
  Last read 00:00:09, last write 00:00:09, hold time is 90, keepalive interval is 30 seconds

# 이떄 패킷에는 R1에서 설정한 holdtime 만 전달 되며, R2에서는 해당 holdtime 에서 1/3으로 keepalive를 설정 한다.
# 또한 더 작은 holdtime이 적용 하기 위해서는 open msaage 를 통해서만 holdtime을 변경 된 사항을 전달 하기 때문에 
# 일시적으로 네이버를shutdown 후 테스트 진행 되었다.
# 만약 open message를 보내지 않을 경우는 해당 장비에서만  해당 holdtime 이 적용 된다.
# clear ip BGP * 통해 세션을 다시 연결 할 수 있다.

 



# 인증을 위해 패스워드를 입력 하며 , 입력시 네이버가 끊어 진다.
R1(config-router)#neighbor 10.10.12.2 password cisco
R1(config-router)#
*Feb 24 15:40:23.527: %TCP-6-BADAUTH: No MD5 digest from 10.10.12.2(179) to 10.10.12.1(29149)
*Feb 24 15:40:24.235: %TCP-6-BADAUTH: No MD5 digest from 10.10.12.2(179) to 10.10.12.1(29149)
*Feb 24 15:40:24.243: %TCP-6-BADAUTH: No MD5 digest from 10.10.12.2(179) to 10.10.12.1(29149)

# 반대 장비도 인증 설정 을 하게 되면 인증을 확인 할 수 있다.
R2(config-router)#neighbor 10.10.12.1 password cisco
R2(config-router)#
*Feb 24 15:41:25.039: %BGP-5-ADJCHANGE: neighbor 10.10.12.1 Up

# 해당 구간에 패킷에 tcp해더에 md5 인증을 하겠다는 옵션이 추가 되었다.

 


#Announcing Networks in BGP
• Manually configure networks to be announced.
• Use redistribution from IGP.
## 동시에 할 경우 재분배 보다 network 로 광고 하는 것이 우선이 되기 때문에 필터링 기법을 사용 한다.

# 재분배를 통해 네트워크 광고된 내용을 확인 할 경우 origin code ?를 확인 할 수 있다.
R1(config-router)#redistribute connected   
R1(config-router)#do show ip bgp         
BGP table version is 16, local router ID is 1.1.1.1
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.1/32       0.0.0.0                  0         32768 ?
*> 10.10.12.0/24    0.0.0.0                  0         32768 ?
*> 10.10.13.0/24    0.0.0.0                  0         32768 ?
*> 11.11.11.11/32   0.0.0.0                  0         32768 ?
*> 111.111.111.111/32
                    0.0.0.0                  0         32768 ?

# network를 통해 네트워크 광고된 내용을 확인 할 경우 origin code i를 확인 할 수 있다.
R1(config-router)#do show ip bgp
BGP table version is 32, local router ID is 1.1.1.1
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.1/32       0.0.0.0                  0         32768 i

# 만약 자신의 RIB에 없는 정보를 BGP table로 광고 하면 광고가 되지 않는다.
R1(config-router)#network 1.1.1.2 mask 255.255.255.255
R1(config-router)#do show ip bgp                     
BGP table version is 32, local router ID is 1.1.1.1
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.1/32       0.0.0.0                  0         32768 i


#R3에서 광고를 할 경우 R1 에서는 32bit로 해당 mask로 재분베 되는 것 을 확인 할 수 있다.
#기본적으로 BGP  auto-summary가 disable 되어 있기 때문에 메이저 네트워크로 광고 되지 않는다.

R3(config-router)#redistribute connected

R1#show ip bgp
BGP table version is 9, local router ID is 111.111.111.111
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
*> 3.3.3.3/32       10.10.12.2                         20000 456 789 i
*                   10.10.13.3               0         10000 789 i
*> 10.10.12.0/24    0.0.0.0                  0         32768 ?
*> 10.10.13.0/24    0.0.0.0                  0         32768 ?
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
*> 111.111.111.111/32
                    0.0.0.0                  0         32768 ?

# 패킷에서도 해당 마스크를 확인 가능 하다.

 


# R3에서 auto summary 설정시 메이저 네트워크로 광고 되는 것 을 확인 할 수 있다.
# 또한 show ip bgp 에서 summary 된 네트워크는 mask 가 안나오며, 메이저 네트워크로 summary로 된것을 확 인 할 수 있다.
R3(config-router)#auto-summary 
R1#show ip bgp

   Network          Next Hop            Metric LocPrf Weight Path
*> 3.0.0.0          10.10.12.2                         20000 456 789 ?
*                   10.10.13.3               0         10000 789 ?
*> 10.0.0.0         10.10.12.2                         20000 456 789 ?
*                   10.10.13.3               0         10000 789 ?
*> 10.10.12.0/24    0.0.0.0                  0         32768 ?
*> 10.10.13.0/24    0.0.0.0                  0         32768 ?
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
*> 33.0.0.0         10.10.12.2                         20000 456 789 ?
*                   10.10.13.3               0         10000 789 ?
*> 111.111.111.111/32
                    0.0.0.0                  0         32768 ?
R1#show ip route

B    33.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
B    3.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
     111.0.0.0/32 is subnetted, 1 subnets
C       111.111.111.111 is directly connected, Loopback0
     10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
B       10.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
C       10.10.12.0/24 is directly connected, Ethernet1/0
C       10.10.13.0/24 is directly connected, Ethernet1/1
     11.0.0.0/32 is subnetted, 1 subnets
C       11.11.11.11 is directly connected, Loopback0

# 패킷상 메이저 네트워크가 광고 되는 것을 확인 할 수있다

 


# auto summary network 광고시에 네트워크 주소로 메이저 네트워크로도 광고가 가능 하다.
R3(config-router)#auto-summary 
R3(config-router)# network 3.0.0.0

...
R1#show ip route

B    33.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
B    3.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
     111.0.0.0/32 is subnetted, 1 subnets
C       111.111.111.111 is directly connected, Loopback0
     10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
B       10.0.0.0/8 [20/0] via 10.10.12.2, 00:00:15
C       10.10.12.0/24 is directly connected, Ethernet1/0
C       10.10.13.0/24 is directly connected, Ethernet1/1
     11.0.0.0/32 is subnetted, 1 subnets
C       11.11.11.11 is directly connected, Loopback0



Simple IGP-to-BGP redistribution
- BGP광고시 재분배를 통해 광고 하는 것이 더 간단 하다.
- 하지만 원치 않는 네트워크 까지 광고과 되는 단점이 있다.
- 그러한 위험성으로 필터 정책을 함께 사용 해야 한다.
- SP망에서는 재분배 네트워크에 대하여 필터 되는 경우가 많기 때문에 , network로 광고하는 것이 좋다.
-> 만약 재분배 하는 상황일 경우 route-map 을 이용하여 origin code를 변경 하는 것이 좋다.

#distrbute 필터
- distrubute-list 를 이용 하여 네트워크 대역을 차단 할 수 있다.

router (config-router)# router bgp <AS>
router (config-router)# redistribute <IGP>
router (config-router)# distrubute-list <ACL> out <IGP>
router (config-router)# exit
router (config-# access-list <ACL> permit <network>

#Redistribution using route-maps
-아래 정보가 변경가능 하다.

– Metric
– Next-hop
– Community

 

 




Configuring Classless BGP
- BGP 는 CIDR을 지원 한다 -> summary 지원 
- 192.168.0.0/16 = 192.168.0.0 255.255.0.0
- BGP 기본 정책이 no auto-summary 이기 때문에 마스크를 수동으로 직접 입력 하여 summary 

# 아래와 같이 설정 가능 하다 (기본 network 광고 )
router(config-router)# network ip-prefix-address mask subnet-mask

*만약 192.168.10.0/24 로 RIB에 올라가있는 경우에 BGP테이블에 16bit로 BGP테이블로 올리고 싶은 경우 
임의로 해당 대역으로 staic 하게 null 0로 주면 해당 RIB를 참조 하여 BGP 테이블에 올릴 수 있다.
ex) ip route 192.168.0.0 255.255.0.0 null 0
-> 이러한 경우 null 0 를 가기전에 192.168.10.0/24 가 longgest match 로 더 자세한 네트워크이기때문에 
16bit로 정상 적으로 광고 될 수 있다.

 

 



Aggregating BGP Networks
- BGP에서 축약의 의미이다
- summary 에서와 같이 summary 된 네트워크를 보내지만, 그 summary 된 네트워크와 summary 되지 않은 자세한 
네트워크 까지 같이 보낸다.
- 이때 옵션을 통해 자세한 네트워크만 보낼 것인지 summary 한 네트워크 만 보낼지 ,같이 보낼지 옵션을 확인 할 수 있다.


# 아래와 같이 Aggregating BGP Networks 를 구성 가능 
# 이때 SUMMARY는 RIB에 있는 정보를 합치지만 Aggregating 는 BGP tabl 에 해당 자세한 네트워크가 있어야 한다.
#The aggregate will be announced if there is at least one network  in the specified range in the BGP table.
-> 적어도 1개의 네트워크 정보가 있을때 까지 네트워크 정보를 광고 한다.
router(config-router)# aggregate-address address-prefix mask

# summary-only 옵션시 자세한 네트워크를 보내지 않고 bgp aggregate 정보만 보낸다.
->개별적 네트워크에 대한 플래핑 현상을 줄일 수 있지만, multihomed customers  에서 문제가 될 수 있다.
router(config-router)# aggregate-address address-prefix mask summary-only

#192.168.0.0/20 bit 를 기본적으로 광고 하지만,16.0/20 은 개별 네트워크와
aggregate 네트워크까지, 32.0/20 은 aggregate 네트워크만 볼경우 아래와 같이 입력 하면 된다.

 

 


# 32.0,33.0 은 자신의 bgp table에서는 suppressed 된 것을 확인 가능 하며 해당 suppressed 된 네트워크는 광고 되지 않는다.


BGP Conditional Route Injection

- 네트워크를 쪼개는 개념-> 네트워크 분산  
- 덜 자세한 네트워크를 좀더 자세한 네트워크로 대체 한다.

BGP Support for TTL Security Check

- bgp와 bgp가 네이버를 맺을떄  (EBGP)기본적으로 TTL은 1로 설정 되어 간다.-> 즉 한 1홉 관계와만 BGP네이버가 된다.
- 만약,1홉 이상의 장비와 네이버를 맺기 위해 TTL을 수정한다.
- 설정시 기본  254로 255-254=1 의 값으로 TTL이 설정 되며,
만약 3홉까지 설정시에는 252로 설정 해야 3홉 까지 설정 가능 하다 (255-252=3)
*EBGP TTL: 1 IBGP TTL:255

# TTL security 설정 방법
router (config-router)#neighbor neighbor-address ttl-security hops hop-count







반응형

'network > ccie-bgp' 카테고리의 다른 글

Configuring a Transit AS  (0) 2016.03.04
Working with a Transit AS  (0) 2016.03.04
Processing BGP Routes  (0) 2016.02.26
Establishing BGP Sessions  (0) 2016.02.26
BGP Path Attributes  (0) 2016.02.26