【BGP】No-Exportコミュニティ 動作確認 Cisco

 BGPのNo-Exportコミュニティは、プレフィックスが自ASの外へ広告されないようにするために使用することができます。 以下の構成で、R1から広告されるプレフィックスに、No-Exportコミュニティを付与し、そのプレフィックスがどのルータまで広告されるのかを確認します。

スポンサーリンク

BGPの基本設定

まず、BGPの基本設定(AS番号、ネイバー、広告するプレフィックス)をします。

R1(config)# router bgp 1
R1(config-router)# network 1.1.1.1 mask 255.255.255.255
R1(config-router)# neighbor 192.168.12.2 remote-as 25
R2(config)# router bgp 25
R2(config-router)# neighbor 192.168.12.1 remote-as 1
R2(config-router)# neighbor 192.168.25.5 remote-as 25
R2(config-router)# neighbor 192.168.23.3 remote-as 3
R3(config)# router bgp 3
R3(config-router)# neighbor 192.168.23.2 remote-as 25
R5(config) #router bgp 25
R5(config-router)# neighbor 192.168.25.2 remote-as 25

R1のプレフィックス1.1.1.1/32が各ルータまで広告されていることを確認します。

R2# show ip bgp 
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       192.168.12.1             0             0 1 I
R3# show ip bgp
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       192.168.23.2                           0 25 1 i
R5# show ip bgp
BGP table version is 2, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 1.1.1.1/32       192.168.12.1             0    100      0 1 i
スポンサーリンク

No-Exportコミュニティ設定

 R1で広告するプレフィックス1.1.1.1/32にNo-Exportコミュニティを付与します。まず、プレフィックスをプレフィックスリストで定義します。

R1(config)# ip prefix-list LOOPBACK0 permit 1.1.1.1/32

 次にroute-mapコマンドで、上で設定したプレフィックスリストに対して、コミュニティをset communityコマンドで付与します。

R1(config)# route-map NO-EXPORT permit 10 
R1(config-route-map)# match ip address prefix-list LOOPBACK0
R1(config-route-map)# set community no-export
R1(config-route-map)# route-map NO-EXPORT permit 1000

ルートマップのシーケンス1000による暗黙のDeny対策を忘れないようにしてください。

上のルートマップをネイバーR2の出力側に適用します。

コミュニティ値を広告するには、ネイバー設定でsend-communityコマンドの追加も必要です。

R1(config)# router bgp 1 
R1(config-router)# neighbor 192.168.12.2 route-map NO-EXPORT out
R1(config-router)# neighbor 192.168.12.2 send-community

R1でBGPプロセスをクリアし、ポリシーを反映します。

R1# clear ip bgp *
R1#
%BGP-5-ADJCHANGE: neighbor 192.168.12.2 Down User reset
%BGP_SESSION-5-ADJCHANGE: neighbor 192.168.12.2 IPv4 Unicast topology base removed
 from session  User reset
%BGP-5-ADJCHANGE: neighbor 192.168.12.2 Up

では、各ルータのBGPテーブルを確認します。

R2#show ip bgp 
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  1.1.1.1/32       192.168.12.1             0             0 1 i
R3#show ip bgp
R3#
R5#show ip bgp
BGP table version is 2, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 * i 1.1.1.1/32       192.168.12.1             0    100      0 1 i

R3で1.1.1.1/32のプレフィックスを受信していないことが確認できます。

No-Exportコミュニティを付与されたプレフィックスを受信したR2は、内部BGPのみにフレフィックスを広告し、外部BGP(AS外)には広告しないことが確認できました。

その他 BGP関連記事は   >>  ルーティングプロトコル(BGP)まとめ << より参照できます。

コメント