スポンサーリンク
スポンサーリンク

BGP – set as-path prepend 設定例

BGPのBest-Pathについて、Cisco CMLで演習してみようと思います

① NW構成通りにコンフィグを作成

② AS-Path Prependにより
・設定内容確認

 ・Pathを追加してbest-pathがどう変わるか?

③ bgp bestpath as-path ignoreでPathが無視されるのか?

BGP Best path Selection (Cisco)

BGP Best path Selection
Weight (Highest)
Local_Pref(Highest)
Prefer locally originated
AS_Path (Shortest)
Origin Type (Lowest)
MED (Lowest)
Prefer eBGP Over iBGP
IGP metric to the BGP Next hop  (Lowest)
Oldest Path
Router ID source  (Lowest)
Minimum Cluster list length
Neighbor address (Lowest)

NW構成 (Cisco Modeling Labs利用)

R1: loopback0: 1.1.1.1
R2: loopback0: 2.2.2.2
R3: loopback0: 3.3.3.3
R4: loopback0: 4.4.4.4
R5: loopback0: 5.5.5.5
R6: loopback0: 6.6.6.6
eBGP Peer : R1 ⇔ R2、 R1 ⇔ R3、 R2 ⇔ R4、R3 ⇔ R5
eBGP Peer : R4 ⇔ R5、 R4 ⇔ R6、 R5 ⇔ R6 

config

R1-config

hostname R1
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.12.1.1 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.13.1.1 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 100
bgp log-neighbor-changes
redistribute connected
neighbor 10.12.1.2 remote-as 200
neighbor 10.13.1.3 remote-as 300
!
control-plane
!
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R1#

R2-config

hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.12.1.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.24.1.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 200
bgp log-neighbor-changes
redistribute connected
neighbor 10.12.1.1 remote-as 100
neighbor 10.24.1.4 remote-as 400
!
control-plane
!
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R2#

R3-config

hostname R3
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.13.1.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.35.1.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 300
bgp log-neighbor-changes
redistribute connected
neighbor 10.13.1.1 remote-as 100
neighbor 10.35.1.5 remote-as 400
!
control-plane
!
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R3#

R4-config

hostname R4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.24.1.4 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.45.1.4 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
ip address 10.46.1.4 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router ospf 1
passive-interface GigabitEthernet0/0
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 400
bgp log-neighbor-changes
redistribute connected
neighbor 5.5.5.5 remote-as 400
neighbor 5.5.5.5 update-source Loopback0
neighbor 6.6.6.6 remote-as 400
neighbor 6.6.6.6 update-source Loopback0
neighbor 10.24.1.2 remote-as 200
!
control-plane
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R4#

R5-config

hostname R5
!
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.35.1.5 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.45.1.5 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
ip address 10.56.1.5 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router ospf 1
passive-interface GigabitEthernet0/0
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 400
bgp log-neighbor-changes
redistribute connected
neighbor 4.4.4.4 remote-as 400
neighbor 4.4.4.4 update-source Loopback0
neighbor 6.6.6.6 remote-as 400
neighbor 6.6.6.6 update-source Loopback0
neighbor 10.35.1.3 remote-as 300
!
control-plane
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R5#

R6-config

hostname R6
!
interface Loopback0
ip address 6.6.6.6 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.46.1.6 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.56.1.6 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router ospf 1
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 400
bgp log-neighbor-changes
redistribute connected
neighbor 4.4.4.4 remote-as 400
neighbor 4.4.4.4 update-source Loopback0
neighbor 5.5.5.5 remote-as 400
neighbor 5.5.5.5 update-source Loopback0
!
control-plane
!
line con 0
line aux 0
line vty 0 4
login
transport input none
!
no scheduler allocate
!
end

R6#

確認コマンド

R1から見た show ip bgp 6.6.6.6

R1#show ip bgp 6.6.6.6
BGP routing table entry for 6.6.6.6/32, version 7
Paths: (2 available, best #2, table default)
Advertised to update-groups:
2
Refresh Epoch 2
300 400
10.13.1.3 from 10.13.1.3 (3.3.3.3)
Origin incomplete, localpref 100, valid, external
rx pathid: 0, tx pathid: 0
Refresh Epoch 2
200 400
10.12.1.2 from 10.12.1.2 (2.2.2.2)
Origin incomplete, localpref 100, valid, external, best 
 //bestになる理由:Router ID source  (Lowest)
rx pathid: 0, tx pathid: 0x0

R1から見た show ip bgp

R1#show ip bgp
Network    Next Hop  Metric LocPrf Weight    Path
*  6.6.6.6/32   10.13.1.3            0   300 400 ?
*> 10.12.1.2                   0   200 400 ?
 // 「>」が付いている方が best-path

R1から見た show ip route 6.6.6.6

R1#show ip route 6.6.6.6
Routing entry for 6.6.6.6/32
Known via “bgp 100”, distance 20, metric 0
Tag 200, type external
Last update from 10.12.1.2 03:19:49 ago
Routing Descriptor Blocks:
* 10.12.1.2, from 10.12.1.2, 03:19:49 ago
Route metric is 0, traffic share count is 1
AS Hops 2
Route tag 200
MPLS label: none

set as-path prepend でPathを追加してみる

set as-path prependのための設定内容

ip prefix-list AS-PRE seq 5 permit 6.6.6.6/32
// 6.6.6.6の経路に対して、PREPENDします。
!
route-map BGP-PREPEND permit 10
match ip address prefix-list AS-PRE
set as-path prepend 1000 2000
// 1000 と 2000をPathを追加します。これは実際にPathを通ったわけではなく、設定上追加されただけです。また、as-path を追加することはできますが、as-path を削除することはできません。
!
route-map BGP-PREPEND permit 20router bgp 200
neighbor 10.12.1.1 route-map BGP-PREPEND out

R1から見た show ip bgp 6.6.6.6

R1#show ip bgp 6.6.6.6
BGP routing table entry for 6.6.6.6/32, version 6
Paths: (2 available, best #2, table default)
Advertised to update-groups:
3
Refresh Epoch 1
200 1000 2000 400 //1000 2000が追加されて結果
10.12.1.2 from 10.12.1.2 (2.2.2.2)
Origin incomplete, localpref 100, valid, external
rx pathid: 0, tx pathid: 0

Refresh Epoch 2
300 400
10.13.1.3 from 10.13.1.3 (3.3.3.3)
Origin incomplete, localpref 100, valid, external, best
//1000 2000が追加されて結果、Best Pathは 10.13.1.3へ移った
rx pathid: 0, tx pathid: 0x0

R1から見た show ip bgp

R1#show ip bgp
Network         Next Hop  Metric LocPrf Weight   Path
* 6.6.6.6/32       10.12.1.2                                  0         200 1000 2000 400 ?
*>                      10.13.1.3                                  0                          300 400 ?
 // 「>」が付いている方が best-pathで、1000 2000が追加されて結果、Best Pathは 10.13.1.3へ移った

R1から見た show ip route 6.6.6.6

R1#show ip route 6.6.6.6
Routing entry for 6.6.6.6/32
Known via “bgp 100”, distance 20, metric 0
Tag 300, type external
Last update from 10.13.1.3 00:14:30 ago
Routing Descriptor Blocks:
* 10.13.1.3, from 10.13.1.3, 00:14:30 ago
Route metric is 0, traffic share count is 1
AS Hops 2
Route tag 300
MPLS label: none

set as-path prepend でPathを追加してみる

router bgp xxx
bgp bestpath as-path ignore //IOS-XE 15.9 ではas-path ignoreコマンドは無くなっていました。 
BGPALL
スポンサーリンク
スポンサーリンク