目次
はじめに
こんにちは。ネットワークエンジニアの「だいまる」です。
今回はBGP Attributeシリーズとして、「AS Path」をまとめていきたいと思います。
AS Pathとは?
概要
BGP Attribute(属性)の1つである「AS Path」は、どのASを経由したのかを表すASリストになります。
主に長さが短いパスがベストパスとなり、Prependといった機能を利用することで意図的に長さを変更することもできます。

方法によってはAS Pathの書き換えも可能です!
設定方法(Cisco IOS)
AS Pathの変更には、いくつか方法がありますが、今回はPrependを確認し、その他の方法は別の記事で紹介することにします。
方法:Prepend
コマンドは以下の通りとなります。
Route-mapによる設定
#prefix-listの定義
ip prefix-list <リスト名> permit <IP Range>/<prefix>
#route-mapの定義
route-map <マップ名> permit 10
match ip address prefix-list <リスト名>
set as-path prepend <AS番号>
#BGPへの設定適用
router bgp <AS番号>
neighbor <NeighborのIPアドレス> route-map <マップ名> [in|out]
動作確認
検証構成
前回まで同様の構成になります。
事前確認(Router8)
事前確認としてBGPテーブルを参照してみます。
Router8#show ip bgp
BGP table version is 10, local router ID is 10.30.8.1
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,
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.10.1.1/32 192.168.4.1 0 200 100 i
*> 192.168.3.1 0 100 i
* 10.10.2.1/32 192.168.4.1 0 200 100 i
*> 192.168.3.1 0 0 100 i
* 10.10.3.1/32 192.168.4.1 0 200 100 i
*> 192.168.3.1 0 100 i
* 10.10.4.1/32 192.168.4.1 0 200 100 i
*> 192.168.3.1 0 100 i
*> 10.20.5.1/32 192.168.4.1 0 200 i
* 192.168.3.1 0 100 200 i
*> 10.20.6.1/32 192.168.4.1 0 0 200 i
* 192.168.3.1 0 100 200 i
*> 10.20.7.1/32 192.168.4.1 0 200 i
* 192.168.3.1 0 100 200 i
* 10.40.9.1/32 192.168.4.1 0 200 400 i
*> 192.168.3.1 0 100 400 i
* 10.40.19.1/32 192.168.4.1 0 200 400 i
*> 192.168.3.1 0 100 400 i
Router8#
設定変更(Router8)
Router8でAS200から受信している「10.40.9.1」と「10.40.19.1」の2経路にAS200を3つ付与したいと思います。
RRouter8#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router8(config)#ip prefix-list AS400 seq 10 permit 10.40.0.0/16 ge 32
Router8(config)#route-map AS400_Prepend permit 10
Router8(config-route-map)#match ip address prefix-list AS400
Router8(config-route-map)#set as-path prepend 200 200 200
Router8(config)#router bgp 300
Router8(config-router)#neighbor 192.168.4.1 route-map AS400_Prepend in
この状態で事後確認としてRouter8で経路を見ていきたいと思います。
事後確認(Router8)
以下の結果の通り、AS200(next hop:192.168.4.1)からの経路にAS200が3つ付与されていることがわかります。
Router8#show ip bgp
BGP table version is 31, local router ID is 10.30.8.1
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,
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.10.1.1/32 192.168.3.1 0 100 i
*> 10.10.2.1/32 192.168.3.1 0 0 100 i
*> 10.10.3.1/32 192.168.3.1 0 100 i
*> 10.10.4.1/32 192.168.3.1 0 100 i
*> 10.20.5.1/32 192.168.3.1 0 100 200 i
*> 10.20.6.1/32 192.168.3.1 0 100 200 i
*> 10.20.7.1/32 192.168.3.1 0 100 200 i
*> 10.40.9.1/32 192.168.3.1 0 100 400 i
* 192.168.4.1 0 200 200 200 200 100 400 i
*> 10.40.19.1/32 192.168.3.1 0 100 400 i
* 192.168.4.1 0 200 200 200 200 100 400 i
Router8#
最後に
今回もBGPのAttribute(属性)の1つである「AS Path」についてまとめました。
この記事でみなさんの理解を少しでも深めることができていれば幸いです。


