BGP weightアトリビュート、条件付きアドバタイズメント、allowas-in

トポロジ



条件
・R5 にて sh ip bgp が下記のようになるようにしてください。
Network Next Hop Metric LocPrf Weight Path
*> 22.22.22.0/24 15.15.15.1 100 100 300 i
・上記状態にするために R5 のその他の経路に影響を与えないようにしてください。

・R2 Lo1(222.222.222.222/24) へ向かうルートはすべて R2-R3 間のリンクを通るように
 してください。
・上記ルートが down となった場合のみ R2-R5 のルートを通るようにしてください。
・設定は R2 のみに行ってください。

・R8 の Lo0(88.88.88.88/24) を BGP にアドバタイズしてください。
・R3とSW3でAPパスとしてAS100のBGPアップデートを受け入れるように設定してください。
・この条件を達成するために R2 には設定しないでください。


まず下記設定からスタートです。

R1
interface FastEthernet0/0
 ip address 16.16.16.1 255.255.255.0
!
interface FastEthernet0/1
 ip address 15.15.15.1 255.255.255.0
!
router eigrp 100
 redistribute ospf 1 metric 100 1 255 1 1500
 network 16.16.16.0 0.0.0.255
 no auto-summary
!
router ospf 1
 redistribute eigrp 100 subnets
 network 15.15.15.0 0.0.0.255 area 0
!
router bgp 100
 no synchronization
 neighbor 15.15.15.5 remote-as 200
 neighbor 16.16.16.6 remote-as 100
 neighbor 36.36.36.3 remote-as 100
 no auto-summary

R2
interface lo0
 ip address 22.22.22.22 255.255.255.0
!
interface lo1
 ip address 222.222.222.222 255.255.255.0
!
interface FastEthernet0/0
 ip address 23.23.23.2 255.255.255.0
!
interface FastEthernet0/1
 ip address 25.25.25.2 255.255.255.0
!
router eigrp 100
 redistribute ospf 1 metric 100 1 255 1 1500
 network 23.23.23.0 0.0.0.255
 no auto-summary
!
router ospf 1
 redistribute eigrp 100 subnets
 network 25.25.25.0 0.0.0.255 area 0
!
router bgp 300
 no synchronization
 network 222.222.222.0 mask 255.255.255.0
 neighbor 23.23.23.3 remote-as 100
 neighbor 25.25.25.5 remote-as 200
 no auto-summary


R3
interface Loopback0
 ip address 33.33.33.33 255.255.255.0
!
interface FastEthernet0/0
 ip address 23.23.23.3 255.255.255.0
!
interface FastEthernet0/1
 ip address 36.36.36.3 255.255.255.0
!
router eigrp 100
 network 23.23.23.0 0.0.0.255
 network 36.36.36.0 0.0.0.255
 no auto-summary
!
router bgp 100
 no synchronization
 network 33.33.33.0 mask 255.255.255.0
 neighbor 16.16.16.1 remote-as 100
 neighbor 23.23.23.2 remote-as 300
 neighbor 36.36.36.6 remote-as 100
 no auto-summary

R5
interface FastEthernet0/0
 ip address 25.25.25.5 255.255.255.0
!
interface FastEthernet0/1
 ip address 15.15.15.5 255.255.255.0
!
router ospf 1
 network 15.15.15.0 0.0.0.255 area 0
 network 25.25.25.0 0.0.0.255 area 0
!
router bgp 200
 no synchronization
 neighbor 15.15.15.1 remote-as 100
 neighbor 25.25.25.2 remote-as 300
 no auto-summary

R6
interface FastEthernet0/0
 ip address 16.16.16.6 255.255.255.0
!
interface FastEthernet0/1
 ip address 36.36.36.6 255.255.255.0
!
interface Ethernet1/0
 ip address 67.67.67.6 255.255.255.0
 duplex half
!
router eigrp 100
 redistribute rip metric 100 1 255 1 1500
 network 16.16.16.0 0.0.0.255
 network 36.36.36.0 0.0.0.255
 no auto-summary
!
router rip
 version 2
 redistribute eigrp 100 metric 3
 network 67.0.0.0
!
router bgp 100
 no synchronization
 neighbor 16.16.16.1 remote-as 100
 neighbor 36.36.36.3 remote-as 100
 neighbor 67.67.67.7 remote-as 54
 no auto-summary

R7
interface Loopback0
 ip address 77.77.77.77 255.255.255.0
!
interface Ethernet1/0
 ip address 67.67.67.7 255.255.255.0
!
router rip
 version 2
 network 67.0.0.0
!
router bgp 54
 no synchronization
 network 77.77.77.0 mask 255.255.255.0
 neighbor 67.67.67.6 remote-as 100
 no auto-summary


まず一つ目の条件から考えたいと思います。
・R5 にて sh ip bgp が下記のようになるようにしてください。
Network Next Hop Metric LocPrf Weight Path
*> 22.22.22.0/24 25.25.25.2 0 100 300 i


現状 R5 にて sh ip bgp を見ると 22.22.22.0/24 宛の経路は 25.25.25.2 が優先経路に
なっているものの条件にある Weight値が 100 になっていません。


R5#sh ip bgp
BGP table version is 4, local router ID is 25.25.25.5
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
*  22.22.22.0/24    15.15.15.1                             0 100 300 i
*>                  25.25.25.2               0             0 300 i


Weight値を 100 になるように R5 に設定を入れてやります。

R5
ip prefix-list 22 permit 22.22.22.0/24

route-map WEIGHT permit 10
match ip address prefix-list 22
set weight 100

route-map WEIGHT permit 20

router bgp 200
neighbor 25.25.25.2 route-map WEIGHT in

上記設定をして、再度 sh ip bgp を確認すると、Weight が 100 になったことがわかります。


R5#sh ip bgp
BGP table version is 4, local router ID is 25.25.25.5
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
*> 22.22.22.0/24    25.25.25.2               0           100 300 i
*                   15.15.15.1                             0 100 300 i



次の条件いきます。
・R2 Lo1(222.222.222.222/24) へ向かうルートはすべて R2-R3 間のリンクから受け取る
 ようにしてください。
・上記ルートが down となった場合のみ R2-R5 のルートを通るようにしてください。
・設定は R2 のみに行ってください。

現状、R5 にて sh ip bgp を見ると、222.222.222.0/24 へのルートは R1,R2 から
それぞれルートをもらっており、R2 からもらっているルートを優先としております。


R5#sh ip bgp
*  222.222.222.0    15.15.15.1                             0 100 300 i
*>                  25.25.25.2               0             0 300 i



R2-R3間のリンクから受け取るとあるので、R2-R5経由のルート自体を受け取らない
設定にしてやります。経路の優先度で R3 経由を優先させるのであれば、AS-PATH
で設定できそうですが、R2-R5 の経路自体を受け取らないようにするには
条件付きアドバタイズメント機能を使用します。

参考:
http://www.cisco.com/cisco/web/support/JP/100/1007/1007911_cond_adv-j.html

R2
ip prefix-list 23 permit 10 23.23.23.0/24

ip prefix-list 222 permit 10 222.222.222.0/24

route-map NON_EXIST permit 10
match ip address prefix-list 23

route-map ADVERTISE permit 10
match ip address predix-list 222

router bgp 300
neighbor 25.25.25.5 advertise-map ADVERTISE non-exist-map NON_EXIST

R2 の BGPテーブルから 23.23.23.0/24 のエントリが消えた場合、222.222.222.0/24
のルートを R5 にアドバタイズするというものです。

上記設定をして、再度 R5 にて sh ip bgp を見てみると、222.222.222.0/24 への
ルートは R1 側からしかもらっていないことがわかります。



R5#sh ip bgp
*  222.222.222.0    15.15.15.1                             0 100 300 i



条件付アドバタイズメントのステータスを確認するには sh ip bgp neighbor 25.25.25.5
を確認します。



R2#sh ip bgp neighbors 25.25.25.5
BGP neighbor is 25.25.25.5,  remote AS 200, external link
  BGP version 4, remote router ID 25.25.25.5
  BGP state = Established, up for 00:04:08
  Last read 00:00:08, last write 00:00:08, 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:
    InQ depth is 0
    OutQ depth is 0
                         Sent       Rcvd
    Opens:                 84         82
    Notifications:         47         24
    Updates:              391        384
    Keepalives:          1617       1571
    Route Refresh:          0          0
    Unrecognized:         n/a         46
    Total:               2139       2109
  Default minimum time between advertisement runs is 30 seconds

 For address family: IPv4 Unicast
  BGP table version 7, neighbor version 7/0
 Output queue size : 0
  Index 2, Offset 0, Mask 0x4
  2 update-group member
  Condition-map NON_EXIST, Advertise-map ADVERTISE, status: Withdraw
                                 Sent       Rcvd
  Prefix activity:               ----       ----
    Prefixes Current:               3          1 (Consumes 52 bytes)
    Prefixes Total:                 4          1
    Implicit Withdraw:              0          0
    Explicit Withdraw:              1          0
    Used as bestpath:             n/a          0
    Used as multipath:            n/a          0

                                   Outbound    Inbound
  Local Policy Denied Prefixes:    --------    -------
    AS_PATH loop:                       n/a          4
    advertise-map:                        1        n/a
    Total:                                1          4
  Number of NLRIs in the update sent: max 3, min 0

  Connections established 81; dropped 80
  Last reset 00:04:40, due to BGP Notification received, header synchronization problems




その中に Condition-map の行を見ると status が Withdraw となっており、
指定されたルートがアドバタイズされていないことがわかります。
では R2 の BGPテーブルから 23.23.23.0/24 のエントリを消すために R2 の f0/0
を shut します。

R2
interface f0/0
shutdown

条件付きアドバタイズメントのプロセスは 60秒ごとに実行されるとのことなので、
BGP テーブルから指定のルートが消えてから 60秒以内に 条件付きアドバタイズメント
が発動することになります。

で、R5 にて sh ip bgp を見てみます。


R5#sh ip bgp
*> 222.222.222.0    25.25.25.2               0             0 300 i



222.222.222.0/24 のルートを R2 から受け取っていることがわかります。
さらに sh ip bgp neighbor 25.25.25.5 を見てみます。


R2#sh ip bgp neighbors 25.25.25.5
BGP neighbor is 25.25.25.5,  remote AS 200, external link
  BGP version 4, remote router ID 25.25.25.5
  BGP state = Established, up for 00:21:07
  Last read 00:00:06, 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:
    InQ depth is 0
    OutQ depth is 0
                         Sent       Rcvd
    Opens:                 84         82
    Notifications:         47         24
    Updates:              395        389
    Keepalives:          1634       1588
    Route Refresh:          0          0
    Unrecognized:         n/a         46
    Total:               2160       2131
  Default minimum time between advertisement runs is 30 seconds

 For address family: IPv4 Unicast
  BGP table version 15, neighbor version 15/0
 Output queue size : 0
  Index 2, Offset 0, Mask 0x4
  2 update-group member
  Condition-map NON_EXIST, Advertise-map ADVERTISE, status: Advertise
                                 Sent       Rcvd
  Prefix activity:               ----       ----
    Prefixes Current:               2          1 (Consumes 52 bytes)
    Prefixes Total:                 6          2
    Implicit Withdraw:              1          0
    Explicit Withdraw:              3          1
    Used as bestpath:             n/a          1
    Used as multipath:            n/a          0

                                   Outbound    Inbound
  Local Policy Denied Prefixes:    --------    -------
    AS_PATH loop:                       n/a          5
    advertise-map:                        1        n/a
    Bestpath from this peer:              2        n/a
    Total:                                3          5
  Number of NLRIs in the update sent: max 3, min 0

  Connections established 81; dropped 80
  Last reset 00:21:38, due to BGP Notification received, header synchronization problems
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 1
Local host: 25.25.25.2, Local port: 179
Foreign host: 25.25.25.5, Foreign port: 61421

Enqueued packets for retransmit: 0, input: 0  mis-ordered: 0 (0 bytes)

Event Timers (current time is 0x54DD520):
Timer          Starts    Wakeups            Next
Retrans            27          0             0x0
TimeWait            0          0             0x0
AckHold            29         26             0x0
SendWnd             0          0             0x0
KeepAlive           0          0             0x0
GiveUp              0          0             0x0
PmtuAger            0          0             0x0
DeadWait            0          0             0x0

iss: 3798510203  snduna: 3798511045  sndnxt: 3798511045     sndwnd:  15543
irs: 2509650160  rcvnxt: 2509650988  rcvwnd:      15557  delrcvwnd:    827

SRTT: 292 ms, RTTO: 359 ms, RTV: 67 ms, KRTT: 0 ms
minRTT: 16 ms, maxRTT: 300 ms, ACK hold: 200 ms
Flags: passive open, nagle, gen tcbs
IP Precedence value : 6

Datagrams (max data segment is 1460 bytes):
Rcvd: 35 (out of order: 0), with data: 31, total data bytes: 827
Sent: 54 (retransmit: 0, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 27, total data bytes: 841



status が advertise に変わったことがわかります。



ちなみに参考ですが、222.222.222.0/24 への経路をそれぞれから受け取り、
R1 からの経路を優先させるのであれば、AS-PATH PREPEND でうまくいきます。

R2
ip prefix-list 222 permit 222.222.222.0/24

route-map PREPEND permit 10
match ip address prefix-list 222
set as-path prepend 300 300

router bgp 300
neighbor 25.25.25.5 route-map PREPEND out


R5#sh ip bgp
*> 222.222.222.0    15.15.15.1                             0 100 300 i
*                   25.25.25.2               0             0 300 300 300 i


R2 からもらった経路に "300 300" がprependされ、R1 経路が優先されるように
なりました。


次に最後の条件いきます。
・R8 の Lo0(88.88.88.88/24) を BGP にアドバタイズしてください。
・R3とSW3でAPパスとしてAS100のBGPアップデートを受け入れるように設定してください。
・この条件を達成するために R2 には設定しないでください。

最後の条件のために R8 を追加したトポロジとしましたので画像をご確認ください。


R8 の設定をも追記します。(R2も追記)


R8
interface lo0
ip address 88.88.88.88 255.255.255.0

interface e1/0
ip address 28.28.28.8 255.255.255.0

router bgp 100
network 88.88.88.0 mask 255.255.255.0
neighbor 28.28.28.2 remote-as 300

R2
interface e1/0
ip address 28.28.28.2 255.255.255.0

router bgp 300
neighbor 28.28.28.8 remote-as 100




図を見るとわかりますが、R3 と R8 はどちらも AS100 に属しており
ますが、AS300 を挟んで論理的に分離されております。
そのため R3 が R8(88.88.88.0/24) の経路を受け取る際に自AS からの
ルートがループして戻ってきたと判断して破棄してしまいます。
これを受け取れるように設定します。

まず R3 にて sh ip bgp を見てみますが、88.88.88.0/24 へのルートは学習していません。
省きますが、R2 では 88.88.88.0/24 は学習できています。


R3#sh ip bgp
BGP table version is 204, local router ID is 33.33.33.33
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
*> 33.33.33.0/24    0.0.0.0                  0         32768 i
*> 222.222.222.0    23.23.23.2               0             0 300 i



R3
router bgp 100
neighbor 23.23.23.2 allowas-in

R8 router bgp 100
neighbor 28.28.28.2 allowas-in

参考:
http://www.cisco.com/cisco/web/support/JP/111/1117/1117517_allowas-in-bgp-config-example-j.html

これで再度 R3 にて sh ip bgp を見てみます。


R3#sh ip bgp
BGP table version is 210, local router ID is 33.33.33.33
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
*  33.33.33.0/24    23.23.23.2                             0 300 100 i
*>                  0.0.0.0                  0         32768 i
*> 88.88.88.0/24    23.23.23.2                             0 300 100 i
*> 222.222.222.0    23.23.23.2               0             0 300 i




88.88.88.0/24 のルートが AS300-AS100 経由で受け取っていることがわかります。



更新日:2013年5月6日
TOPに戻る