Cisco IOS 設定方法

BGP基本設定 Cisco IOS (Cisco IOS-XE)

BGP基本設定 Cisco IOS

このページはCisco IOS(厳密にはIOS-XEになりますが)を利用してBGPの基本的な設定例を紹介します。
BGPプロトコルの解説は下記になります。

その他のOSでの設定例は下記を参照

設定環境

今回設定したルータは下記のIOS Verを利用して実施しました。
Cisco IOS XE Software, Version 17.03.01a

設定構成図

  • iBGPはloopbackupインターフェイス間で接続
  • eBGPはR12側はGi2,R20側はGi1にて接続
  • AS10内はOSPFにて全てのインターフェイス間で通信が可能
  • AS10の経路広報はR12にて10.10.0.0/8(static null0)をnetworkコマンドで実施
  • AS20の経路広報はR20にて20.0.0.0/8(static null0)をnetworkコマンドで実施

BGPの基本設定

R12のBGP設定コマンドは下記になります。

router bgp 10
 bgp router-id 10.0.0.12
 neighbor 10.0.0.11 remote-as 10
 neighbor 10.0.0.11 update-source Loopback0
 neighbor 10.12.20.20 remote-as 20
 !
 address-family ipv4
  network 10.0.0.0
  neighbor 10.0.0.11 activate
  neighbor 10.12.20.20 activate
 exit-address-family
exit

BGPプロトコルの有効化

(config)#router bgp AS_NUMBER
コマンド引数説明
AS_NUMBER自身のルータのAS番号を設定します。AS番号についてはBGPとはのページに記載

BGP ルータID の設定

(config-router)# bgp router-id BGP_ROUTER_ID
コマンド引数説明
BGP_ROUTER_IDBGPルータIDはIPv4アドレス同様の32bitのフォールドになります。形式的にIPv4アドレスと同じく、AAA.BBB.CCC.DDDと入力します。
BGPのパス選択で利用されます。一般的には固定でかつユーニークにな値を入れます。今回の設定はloopbackインターフェイスのIPアドレスと同じ値を設定しています。
※オプションでinterface を指定することも可能です。

BGPピアの設定

(config-router)# neighbor PEER_ADDRESS remote-as PEER_AS_NUMBER
コマンド引数説明
PEER_ADDRESS接続先のIPアドレスを設定します。
PEER_AS_NUMBER接続先BGPピアのAS番号を設定します。AS番号についてはBGPとはのページに記載

BGPルータ間のneighbor設定方法になります。iBGP,eBGPの違いはAS番号が自身と同一の場合iBGP、異なる場合はeBGPとなります。

BGPのピアの送信元アドレスの指定(オプション)

(config-router)# neighbor PEER_ADDRESS update-source INTERFACE
コマンド引数説明
PEER_ADDRESS接続先のIPアドレスを設定します。
INTERFACEBGPピアのソース(接続元)のインターフェイスを指定します。

設定はオプションになります。設定を行わなければ、BGPパケットを送信するインターフェイスになります。
今回はeBGP側は設定していませんので、eBGP側はパケットを送信するGigabitEthernet1が送信元アドレスになります。

BGP経路のアドバタイズ設定

(config-router-af)# network IP_ADDRESS mask NETMASK
コマンド引数説明
IP_ADDRESS広報する経路のIPアドレスを設定します。
NET_MASK広報する経路のネットマスクを設定します。

NETWORKコマンドによるBGP経路の広報設定にはルーティングテーブルに該当の経路が登録されている必要があります。

今回はBGPで広報するアドレスをstatic(next-hop null0)にて下記の設定してルーティングテーブルに登録しています。

R12(config)#ip route 10.0.0.0 255.0.0.0 null 0

上記設定で10.0.0.0/8がルーティングテーブルに登録されます。

R12#show ip route static 
      10.0.0.0/8 is variably subnetted, 7 subnets, 3 masks
S        10.0.0.0/8 is directly connected, Null0
R12#

今回はアドバタイズ設定方法としてnetworkコマンドを紹介しましたが、ルータ集約のaggreaget-addressコマンドIGPからBGPへの再配布による方法もあります。

BGPピアのアドレスファミリー IPv4 Unicastの有効化

(config-router-af)# neighbor PEER_ADDRESS activate
コマンド引数説明
PEER_ADDRESS接続先のIPアドレスを設定します。

接続先のBGPピアとIPv4 Unicastの経路交換を有効化する設定です。

スポンサーリンク

BGPの設定Config

各ルータのBGPの設定内容

R11

router bgp 10
 bgp router-id 10.0.0.11
 neighbor 10.0.0.12 remote-as 10
 neighbor 10.0.0.12 update-source Loopback0
 !
 address-family ipv4
  neighbor 10.0.0.12 activate
 exit-address-family
exit

R12

router bgp 10
 bgp router-id 10.0.0.12
 neighbor 10.0.0.11 remote-as 10
 neighbor 10.0.0.11 update-source Loopback0
 neighbor 10.12.20.20 remote-as 20
 !
 address-family ipv4
  network 10.0.0.0
  neighbor 10.0.0.11 activate
  neighbor 10.12.20.20 activate
 exit-address-family
exit

R20

router bgp 20
 bgp router-id 20.0.0.20
 neighbor 10.12.20.12 remote-as 10
 !
 address-family ipv4
  network 20.0.0.0
  neighbor 10.12.20.12 activate
 exit-address-family
exit

Config

各装置のshow running-config

BGPの設定結果

R11のshow結果

R11#show ip bgp summary 
BGP router identifier 10.0.0.11, local AS number 10
BGP table version is 4, main routing table version 4
2 network entries using 496 bytes of memory
2 path entries using 288 bytes of memory
2/2 BGP path/bestpath attribute entries using 576 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1384 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs
2 networks peaked at 04:06:58 Jul 25 2020 UTC (02:07:26.230 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.12       4           10     148     144        4    0    0 02:09:22        2
R11#
R11#show ip bgp
BGP table version is 4, local router ID is 10.0.0.11
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, 
              t secondary path, L long-lived-stale,
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  10.0.0.0         10.0.0.12                0    100      0 i
 *>i  20.0.0.0         10.12.20.20              0    100      0 20 i
R11#
R11#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
       n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       H - NHRP, G - NHRP registered, g - NHRP registration summary
       o - ODR, P - periodic downloaded static route, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 6 subnets, 3 masks
B        10.0.0.0/8 [200/0] via 10.0.0.12, 02:10:32
C        10.0.0.11/32 is directly connected, Loopback0
O        10.0.0.12/32 [110/2] via 10.11.12.12, 02:10:34, GigabitEthernet1
C        10.11.12.0/24 is directly connected, GigabitEthernet1
L        10.11.12.11/32 is directly connected, GigabitEthernet1
O        10.12.20.0/24 [110/2] via 10.11.12.12, 02:13:00, GigabitEthernet1
B     20.0.0.0/8 [200/0] via 10.12.20.20, 00:59:51
R11#
R11#ping 20.0.0.20 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.0.0.20, timeout is 2 seconds:
Packet sent with a source address of 10.0.0.11 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/3 ms
R11#

R12のshow結果

R12#show ip bgp summary 
BGP router identifier 10.0.0.12, local AS number 10
BGP table version is 7, main routing table version 7
2 network entries using 496 bytes of memory
2 path entries using 288 bytes of memory
2/2 BGP path/bestpath attribute entries using 576 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1384 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs
2 networks peaked at 04:06:57 Jul 25 2020 UTC (02:00:35.838 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.0.0.11       4           10     137     140        7    0    0 02:02:30        0
10.12.20.20     4           20     138     137        7    0    0 02:00:35        1
R12#
R12#show ip bgp
BGP table version is 7, local router ID is 10.0.0.12
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, 
              t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>   10.0.0.0         0.0.0.0                  0         32768 i
 *>   20.0.0.0         10.12.20.20              0             0 20 i
R12#
R12#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
       n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       H - NHRP, G - NHRP registered, g - NHRP registration summary
       o - ODR, P - periodic downloaded static route, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 7 subnets, 3 masks
S        10.0.0.0/8 is directly connected, Null0
O        10.0.0.11/32 [110/2] via 10.11.12.11, 02:08:10, GigabitEthernet1
C        10.0.0.12/32 is directly connected, Loopback0
C        10.11.12.0/24 is directly connected, GigabitEthernet1
L        10.11.12.12/32 is directly connected, GigabitEthernet1
C        10.12.20.0/24 is directly connected, GigabitEthernet2
L        10.12.20.12/32 is directly connected, GigabitEthernet2
B     20.0.0.0/8 [20/0] via 10.12.20.20, 00:54:42
R12#

R20のshow結果

R20#show ip bgp summary 
BGP router identifier 20.0.0.20, local AS number 20
BGP table version is 6, main routing table version 6
2 network entries using 496 bytes of memory
2 path entries using 288 bytes of memory
2/2 BGP path/bestpath attribute entries using 576 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1384 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs
2 networks peaked at 04:06:57 Jul 25 2020 UTC (02:15:08.643 ago)

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.12.20.12     4           10     152     154        6    0    0 02:15:08        1
R20#
R20#show ip bgp
BGP table version is 6, local router ID is 20.0.0.20
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, 
              t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>   10.0.0.0         10.12.20.12              0             0 10 i
 *>   20.0.0.0         0.0.0.0                  0         32768 i
R20#
R20#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
       n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       H - NHRP, G - NHRP registered, g - NHRP registration summary
       o - ODR, P - periodic downloaded static route, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 3 subnets, 3 masks
B        10.0.0.0/8 [20/0] via 10.12.20.12, 02:16:41
C        10.12.20.0/24 is directly connected, GigabitEthernet1
L        10.12.20.20/32 is directly connected, GigabitEthernet1
      20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S        20.0.0.0/8 is directly connected, Null0
C        20.0.0.20/32 is directly connected, Loopback0
R20#

スポンサーリンク

Cisco IOS 設定方法記事一覧

基本設定

インターネット接続

PPPoE

DS-Lite

OSPF

下記はOSPFのプロトコル解説

ネットワーク解説 OSPF (Open Shortest Path First)

BGP

下記はBGPのプロトコル解説

ネットワーク解説 BGP ( Border Gateway Protocol )

BGP記事一覧

BGP RFC/関連サイト

BGP参考図書

私が所持しているBGP関連の本を紹介します。ただし絶版になっている本も紹介していますのでご容赦ください。

著:サム・ハラビ, 著:ダニー・マクファーソン, 翻訳:鈴木 弥生

その他ネットワーク

-Cisco IOS 設定方法
-, ,