MED (Multi-Exit Discriminator)
オプショナル attributeで他AS ⇒ 自ASに対しどこからパケットが入って来てほしいかのメトリックを調整します。
MEDを利用して、経路制御する簡単なコンフィグで検証します。
優先順位 属性(attribute)
1: Highetst Weight
2: Highest LOCAL_PREF
3: Prefer locally originated
4: Shortest AS_PATH
5: Lowest Origin Type
6: Lowest MED ←ココ
7: Prefer eBGP over iBGP
8: Lowest IGP metric to the BGP NEXT_HOP
9: Oldest Path
10: Lowest Router ID
11: Minimum Cluster list Length
12: Lowest Neighbor Address
NW構成図
[8.8.8.8]と[9.9.9.9]の経路について、MEDによりNext-Hopを変えて制御する。
- 通信経路)R4 -> R2 -> R1 -> 8.8.8.8
R2で[8.8.8.8]に対して、Metric =100
R2で[9.9.9.9]に対して、Metric =200
- 通信経路)R4 -> R3 -> R1 -> 9.9.9.9
R2で[8.8.8.8]に対して、Metric =200
R2で[9.9.9.9]に対して、Metric =100
別ISPの優先経路を指示する形になるので、MEDの優先順位が低いのか・・・?。
各機器コンフィグ
Config-R1
hostname R1
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Loopback8
ip address 8.8.8.8 255.255.255.255
!
interface Loopback9
ip address 9.9.9.9 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 ospf 1
network 1.1.1.1 0.0.0.0 area 0
network 10.12.1.0 0.0.0.255 area 0
network 10.13.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
network 8.8.8.8 mask 255.255.255.255
network 9.9.9.9 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
control-plane
!
end
R1#
Config-R2
hostname R2
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.24.1.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.12.1.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
ip address 10.23.1.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router ospf 1
network 2.2.2.2 0.0.0.0 area 0
network 10.12.1.0 0.0.0.255 area 0
network 10.23.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 10.24.1.4 remote-as 200
neighbor 10.24.1.4 route-map BGP-MED out
!
route-map BGP-MED permit 10
match ip address 1
set metric 100
!
route-map BGP-MED permit 20
match ip address 2
set metric 200
!
!
access-list 1 permit 8.8.8.8
access-list 2 permit 9.9.9.9
!
control-plane
!
end
R2#
Config-R3
hostname R3
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface GigabitEthernet0/0
ip address 10.34.1.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/1
ip address 10.13.1.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
ip address 10.23.1.3 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router ospf 1
network 3.3.3.3 0.0.0.0 area 0
network 10.13.1.0 0.0.0.255 area 0
network 10.23.1.0 0.0.0.255 area 0
!
router bgp 100
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 10.34.1.4 remote-as 200
neighbor 10.34.1.4 route-map BGP-MED out
!
route-map BGP-MED permit 10
match ip address 1
set metric 200
!
route-map BGP-MED permit 20
match ip address 2
set metric 100
!
!
access-list 1 permit 8.8.8.8
access-list 2 permit 9.9.9.9
!
control-plane
!
end
R3#
Config-R4
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.34.1.4 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 200
bgp log-neighbor-changes
network 4.4.4.4 mask 255.255.255.255
neighbor 10.24.1.2 remote-as 100
neighbor 10.34.1.3 remote-as 100
!
control-plane
!
end
R4#
コンフィグ補足
R1
- Loopback0 1.1.1.1/32 はiBGPのPeerとして設定
- Loopback8 8.8.8.8/32 はR1のセグメントとしてR4まで広報する
- Loopback9 9.9.9.9/32 はR1のセグメントとしてR4まで広報する
- iBGPのpeerの経路はOSPFにより広報する
- [8.8.8.8][9.9.9.9]はBGPのNetworkコマンドにより広報する
R2
- Loopback0 2.2.2.2/32 はiBGPのPeerとして設定
- iBGPのpeerの経路はOSPFにより広報する
- [8.8.8.8]をaccess-list 1に設定、MED(metric)を100に設定
- [9.9.9.9]をaccess-list 2に設定、MED(metric)を200に設定
- R4にmetricを広報する(out)
R3
- Loopback0 3.3.3.3/32 はiBGPのPeerとして設定
- iBGPのpeerの経路はOSPFにより広報する
- [8.8.8.8]をaccess-list 1に設定、MED(metric)を200に設定
- [9.9.9.9]をaccess-list 2に設定、MED(metric)を100に設定
- R4にmetricを広報する(out)
R4
- R4とR2をeBGPセッションを張る
- R4とR2をeBGPセッションを張る
MED作用の確認
R4#show ip bgp
R4#show ip bgp
BGP table version is 4, local router ID is 4.4.4.4
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 0.0.0.0 0 32768 i
* 8.8.8.8/32 10.34.1.3 200 0 100 i
*> 10.24.1.2 100 0 100 i <—- MEDによる効果
*> 9.9.9.9/32 10.34.1.3 100 0 100 i <—- MEDによる効果
* 10.24.1.2 200 0 100 i
R4#show ip route bgp
R4#show ip route bgp
Gateway of last resort is not set
B 8.8.8.8 [20/100] via 10.24.1.2, 00:06:32
B 9.9.9.9 [20/100] via 10.34.1.3, 00:06:32
show ip bgp neighbors x.x.x.x advertised-routes
R2#show ip bgp neighbors 10.24.1.4 advertised-routes
Network Next Hop Metric LocPrf Weight Path
*>i 8.8.8.8/32 1.1.1.1 0 100 0 i
*>i 9.9.9.9/32 1.1.1.1 0 100 0 i <—- R2から[9.9.9.9]も広報している
R3#show ip bgp neighbors 10.34.1.4 advertised-routes
Network Next Hop Metric LocPrf Weight Path
*>i 8.8.8.8/32 1.1.1.1 0 100 0 i <—- R3から[8.8.8.8]も広報している
*>i 9.9.9.9/32 1.1.1.1 0 100 0 i
show ip route
R1#show ip route bgp
R1#show ip route bgp
Gateway of last resort is not set
B 4.4.4.4 [200/0] via 2.2.2.2, 00:07:41
R2#show ip route bgp
R2#show ip route bgp
Gateway of last resort is not set
B 4.4.4.4 [20/0] via 10.24.1.4, 00:34:19
B 8.8.8.8 [200/0] via 1.1.1.1, 00:34:12
B 9.9.9.9 [200/0] via 1.1.1.1, 00:34:12
R3#show ip route bgp
R3#show ip route bgp
Gateway of last resort is not set
B 4.4.4.4 [20/0] via 10.34.1.4, 00:34:34
B 8.8.8.8 [200/0] via 1.1.1.1, 00:34:34
B 9.9.9.9 [200/0] via 1.1.1.1, 00:34:34
R4#show ip route bgp
R4#show ip route bgp
Gateway of last resort is not set
B 8.8.8.8 [20/100] via 10.24.1.2, 00:34:31
B 9.9.9.9 [20/100] via 10.34.1.3, 00:34:24