概要

neighbor allowas-inコマンドによって、特定のネイバーから受信するBGPルートについて、AS_PATHによるループ防止を無効化します。neighbor allowas-inコマンドについて解説します。

neighbor allowas-inコマンドとは

BGPルートのループ防止のために、AS_PATHアトリビュートを利用しています。BGPルートに付加されているAS_PATHアトリビュートに自AS番号が含まれていると、ルートはループしているとみなして、受信しません。これによりルートのループ防止を行っています。

neighbor allowas-inコマンドは、特定のネイバーから受信するBGPルートについて、AS_PATHによるループ防止を無効化するための設定です。

neighbor allowas-inコマンドを利用する主なケースは、MPLS-VPNで拠点間を接続しているときです。MPLS-VPNで拠点間を接続して、PE-CE間でBGPを利用するとき、CEルータのAS番号は同じにすることがあります。すると、AS_PATHによるループ防止によってBGPルートは無効になってしまいます。

図 MPLS-VPNでの拠点間の接続 その1
図 MPLS-VPNでの拠点間の接続 その1

そこで、CEルータでneighbor allowas-inコマンドを利用します。BGPルートのAS_PATHアトリビュートに自AS番号が含まれていても、ループしているとみなさずにルートを受信できるようにします。

 図 MPLS-VPNでの拠点間の接続 その2
図 MPLS-VPNでの拠点間の接続 その2

neighbor allowas-inの設定と確認コマンド

コマンドフォーマット

BGPのコンフィグレーションモードでneighbor allowas-inコマンドを設定します。以下のコマンドフォーマットです。

neighbor allowas-in コマンドフォーマット

(config)#router bgp <AS>
(config-router)#neighbor <ip-address> allowas-in [<count>]

<AS> : AS番号
<ip-address> : ネイバーのIPアドレス
<count> : 自AS番号を許容する数。

指定したネイバーから受信したBGPルートについて、<count>までの自AS番号が含まれていても許可します。

確認コマンド

show ip bgp neighborコマンドでネイバーの詳細を見ると、neighbor allowas-inコマンドが設定されていることを確認できます。

show ip bgp neighbor

Copy
  1. R3#show ip bgp neighbors 10.1.3.1
  2. BGP neighbor is 10.1.3.1, remote AS 65001, external link
  3. BGP version 4, remote router ID 1.1.1.1
  4. BGP state = Established, up for 00:02:31
  5. Last read 00:00:31, last write 00:00:31, hold time is 180, keepalive interval is 60 seconds
  6. Neighbor capabilities:
  7. Route refresh: advertised and received(old & new)
  8. Address family IPv4 Unicast: advertised and received
  9. Message statistics:
  10. InQ depth is 0
  11. OutQ depth is 0
  12. Sent Rcvd
  13. Opens: 1 1
  14. Notifications: 0 0
  15. Updates: 1 6
  16. Keepalives: 5 5
  17. Route Refresh: 2 0
  18. Total: 9 12
  19. Default minimum time between advertisement runs is 30 seconds
  20.  
  21. For address family: IPv4 Unicast
  22. BGP table version 3, neighbor version 3/0
  23. Output queue size: 0
  24. Index 1, Offset 0, Mask 0x2
  25. 1 update-group member
  26. My AS number is allowed for 3 number of times
  27. ~省略~

neighbor allowas-inコマンドの設定例

ネットワーク構成

以下のネットワーク構成で、neighbor allowas-inコマンドの設定を考えます。

図 neighbor allowas-in 設定例
図 neighbor allowas-in 設定例

初期設定

各ルータの初期設定の抜粋です。R1-R2間およびR1-R3間でBGPネイバーを確立しています。R2は192.168.1.0/24をBGPでアドバタイズしています。R3は192.168.3.0/24をBGPでアドバタイズしています。

R1 初期設定抜粋(Click)

Copy
  1. hostname R1
  2. !
  3. interface FastEthernet0/0
  4. ip address 10.1.2.1 255.255.255.0
  5. !
  6. interface FastEthernet0/1
  7. ip address 10.1.3.1 255.255.255.0
  8. !
  9. router bgp 65001
  10. no synchronization
  11. bgp router-id 1.1.1.1
  12. bgp log-neighbor-changes
  13. neighbor 10.1.2.2 remote-as 65100
  14. neighbor 10.1.3.3 remote-as 65100
  15. no auto-summary

R2 初期設定抜粋(Click)

Copy
  1. hostname R2
  2. !
  3. interface Loopback0
  4. ip address 192.168.2.2 255.255.255.0
  5. !
  6. interface FastEthernet0/0
  7. ip address 10.1.2.2 255.255.255.0
  8. !
  9. router bgp 65100
  10. no synchronization
  11. bgp router-id 2.2.2.2
  12. bgp log-neighbor-changes
  13. network 192.168.2.0
  14. neighbor 10.1.2.1 remote-as 65001
  15. no auto-summary

R3 初期設定抜粋(Click)

Copy
  1. hostname R3
  2. !
  3. interface Loopback0
  4. ip address 192.168.3.3 255.255.255.0
  5. !
  6. interface FastEthernet0/0
  7. ip address 10.1.3.3 255.255.255.0
  8. router bgp 65100
  9. no synchronization
  10. bgp router-id 3.3.3.3
  11. bgp log-neighbor-changes
  12. network 192.168.3.0
  13. neighbor 10.1.3.1 remote-as 65001
  14. no auto-summary

設定と確認

Step1:AS_PATHによるループ防止の確認

AS_PATHアトリビュートに自AS番号が含まれていると、ループとみなされていることを確認します。R3でBGP UPDATEメッセージのデバッグを有効にして、BGPルートを再度受信します。

R3 AS_PATHによるループ防止の確認

Copy
  1. R3#debug ip bgp updates
  2. BGP updates debugging is on for address family: IPv4 Unicast
  3. R3#clear ip bgp * in
  4. R3#
  5. *Mar 1 00:25:46.339: BGP(0): 10.1.3.1 rcv UPDATE w/ attr: nexthop 10.1.3.1, origin i, originator 0.0.0.0, path 65001 65100, community , extended community
  6. *Mar 1 00:25:46.343: BGP(0): 10.1.3.1 rcv UPDATE about 192.168.3.0/24 -- DENIED due to: AS-PATH contains our own AS;
  7. *Mar 1 00:25:46.347: BGP(0): 10.1.3.1 rcv UPDATE w/ attr: nexthop 10.1.3.1, origin i, originator 0.0.0.0, path 65001 65100, community , extended community
  8. *Mar 1 00:25:46.351: BGP(0): 10.1.3.1 rcv UPDATE about 192.168.2.0/24 -- DENIED due to: AS-PATH contains our own AS;
  9. R3#undebug all
  10. All possible debugging has been turned off

ループとみなされた192.168.2.0/24のBGPルートは受信せずにBGPテーブルにも入っていません。

R3 show ip bgp

Copy
  1. R3#show ip bgp
  2. BGP table version is 4, local router ID is 3.3.3.3
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
  4. r RIB-failure, S Stale
  5. Origin codes: i - IGP, e - EGP, ? - incomplete
  6.  
  7. Network Next Hop Metric LocPrf Weight Path
  8. *> 192.168.3.0 0.0.0.0 0 32768 i
図 AS_PATHによるループ防止
図 AS_PATHによるループ防止

Step2:R3 neighbor allowas-inコマンドの設定

R3で192.168.2.0/24のBGPルートをループしているとみなさないように、neighbor allowas-inコマンドを設定します。

R3 neighbor allowas-in

Copy
  1. router bgp 65100
  2. neighbor 10.1.3.1 allowas-in

Step3:R3 BGPルートの確認

neighbor allowas-inコマンドの設定によって、R3は192.168.2.0/24のBGPルートを受信してベストパスにします。そして、ルーティングテーブルに登録しています。

R3 BGPルートの確認

Copy
  1. R3#show ip bgp
  2. BGP table version is 5, local router ID is 3.3.3.3
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
  4. r RIB-failure, S Stale
  5. Origin codes: i - IGP, e - EGP, ? - incomplete
  6.  
  7. Network Next Hop Metric LocPrf Weight Path
  8. *> 192.168.2.0 10.1.3.1 0 65001 65100 i
  9. * 192.168.3.0 10.1.3.1 0 65001 65100 i
  10. *> 0.0.0.0 0 32768 i
  11. R3#show ip route
  12. ~省略~
  13.  
  14. Gateway of last resort is not set
  15.  
  16. 10.0.0.0/24 is subnetted, 1 subnets
  17. C 10.1.3.0 is directly connected, FastEthernet0/0
  18. B 192.168.2.0/24 [20/0] via 10.1.3.1, 00:03:07
  19. C 192.168.3.0/24 is directly connected, Loopback0
図 neighbor allowas-in
図 neighbor allowas-in

Step4:R2 neighbor allowas-inコマンドの設定

R2でもR3と同様に、neighbor allowas-inコマンドの設定が必要です。

R2 neighbor allowas-in

Copy
  1. router bgp 65100
  2. neighbor 10.1.2.1 allowas-in

Step5:通信確認

ここまでの設定によって、同じAS番号の離れたAS間のネットワークで通信できます。R2/R3のBGPテーブルとルーティングテーブルを確認します。

R2/R3 BGPテーブル ルーティングテーブル

Copy
  1. R2#show ip bgp
  2. BGP table version is 3, local router ID is 2.2.2.2
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
  4. r RIB-failure, S Stale
  5. Origin codes: i - IGP, e - EGP, ? - incomplete
  6.  
  7. Network Next Hop Metric LocPrf Weight Path
  8. * 192.168.2.0 10.1.2.1 0 65001 65100 i
  9. *> 0.0.0.0 0 32768 i
  10. *> 192.168.3.0 10.1.2.1 0 65001 65100 i
  11. R2#show ip route bgp
  12. B 192.168.3.0/24 [20/0] via 10.1.2.1, 00:00:09
Copy
  1. R3#show ip bgp
  2. BGP table version is 5, local router ID is 3.3.3.3
  3. Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
  4. r RIB-failure, S Stale
  5. Origin codes: i - IGP, e - EGP, ? - incomplete
  6.  
  7. Network Next Hop Metric LocPrf Weight Path
  8. *> 192.168.2.0 10.1.3.1 0 65001 65100 i
  9. * 192.168.3.0 10.1.3.1 0 65001 65100 i
  10. *> 0.0.0.0 0 32768 i
  11. R3#show ip route bgp
  12. B 192.168.2.0/24 [20/0] via 10.1.3.1, 00:06:37

そして、192.168.2.0/24と192.168.3.0/24間で通信できることを確認します。R2からR3へPingします。

R2からR3へPing

Copy
  1. R2#ping 192.168.3.3 source 192.168.2.2
  2.  
  3. Type escape sequence to abort.
  4. Sending 5, 100-byte ICMP Echos to 192.168.3.3, timeout is 2 seconds:
  5. Packet sent with a source address of 192.168.2.2
  6. !!!!!
  7. Success rate is 100 percent (5/5), round-trip min/avg/max = 32/38/44 ms

まとめ

ポイント

  • neighbor allowas-inコマンドは、特定のネイバーから受信するBGPルートについて、AS_PATHによるループ防止を無効化します。
  • BGPのコンフィグレーションモードで次のコマンドを入力します。
    • (config-router)#neighbor <ip-address> allowas-in [<count>]

BGPの仕組み