NEC IX ルータの再配送(redistribute)の設定例を紹介します。全てのパターンを紹介しきるのは難しいので、最も使用頻度が高いと推測されるOSPFとBGPの再配送の設定例を紹介します。
設定まとめ
コマンド一覧
再配送に関連するコマンド一覧は以下の通りです。
Router(config)# ip router ospf <proc> Router(config-ospfv2-X)# redistribute bgp <local-as> [<option>...] Router(config)# router bgp <local-as> Router(config-bgp)# address-family ipv4 unicast Router(config-bgp-af4)# redistribute ospf <proc> Router(config-bgp-af4)# redistribute-internal
BGPからOSPFへの再配送
以下のコマンドでBGPからOSPFへの再配送を設定できます。
Router(config)# ip router ospf <proc> Router(config-ospfv2-X)# redistribute bgp <local-as> [<option>...]
ただし、デフォルトではiBGPによって学習したprefixはIGP(Interior Gateway Protocol)へ再配当されない事に注意ください。IGPとは、OSPF, RIP, EIGRP, ISISなど元々はLAN向けに開発されたルーティングプロトコルの総称です。
最近はLAN向けにBGPを使う事も増えてきたので、IGPという言葉を滅多に聞かなくなりました。IGPは若干の時代錯誤がある言葉です。
このデフォルトの挙動を打ち消すには、”redistribute-internal”を指定します。このコマンドはBGPのaddress-familiy ipv4 unicastに対して設定します。
Router(config)# router bgp <local-as> Router(config-bgp)# address-family ipv4 unicast Router(config-bgp-af4)# redistribute-internal
OSPFからBGPへの再配送
以下のコマンドでBGPからOSPFへの再配送を設定できます。
Router(config)# router bgp <local-as> Router(config-bgp)# address-family ipv4 unicast Router(config-bgp-af4)# redistribute ospf <proc>
動作確認
動作確認の構成
以下の環境で動作確認を行います。
|
| 192.168.3.0/24
|
eth1 | .3
+-------+----------+
| VyOS 1.4 |
| R3 |
| Lo:10.3.3.3/32 |
+-------+----------+
eth0 | .3
|
| 192.168.23.0/24
|
G0.0 | .2
+-------+----------+
| NEC IX 2015 |
| R2 |
| Lo:10.2.2.2/32 |
+-------+----------+
G1.0 | .2
|
| 192.168.12.0/24
|
eth1 | .1
+-------+----------+
| VyOS 1.4 |
| R1 |
| Lo:10.1.1.1/32 |
+-------+----------+
eth0 | .1
|
| 192.168.1.0/24
|
初期設定
初期設定はIPアドレスのみとします。NATの設定は入れていません。
動作確認 (1) 事前準備
OSPF
R1, R2間でOSPFを確立します。
[R1:VyOS1.4] set protocols ospf area 0 network '192.168.12.0/24' set protocols ospf redistribute connected
[R2:IX2015] ip router ospf 1 redistribute bgp 65000 metric-type 1 area 0 network 192.168.12.0/24 area 0
R1, R2間でOSPF neighborの確立を確認します。
[R2:IX2015]
R2(config)# show ip ospf neighbor
Neighbor ID Pri State Age IP address Uptime Interface
10.1.1.1 1 FULL/BDR 6 192.168.12.1 0:57:44 GigaEthernet1.0
R2(config)#
R2(config)#
R2(config)#
R2(config)# show ip route ospf
IP Routing Table - 2 entries, 7 hidden, 2039 frees
Entries: 0 Connected, 0 Static, 0 RIP, 2 OSPF, 0 BGP
Codes: C - Connected, S - Static, R - RIP, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, B - BGP
* - Candidate default, s - Summary
Timers: Age
O E2 10.1.1.1/32 [110/20] via 192.168.12.1, GigaEthernet1.0, 0:57:03
O E2 192.168.1.0/24 [110/20] via 192.168.12.1, GigaEthernet1.0, 0:57:03
R2(config)#
BGP
R2, R3間でBGPを確立します。
[R2:IX2015] router bgp 65000 neighbor 192.168.23.3 remote-as 65000
[R3:VyOS1.4] set protocols bgp address-family ipv4-unicast redistribute connected set protocols bgp local-as '65000' set protocols bgp neighbor 192.168.23.2 remote-as '65000'
R2, R3間でBGP neighborの確立を確認します。
[R2:IX2015]
R2(config)# show ip bgp summary
BGP router ID 10.2.2.2, local AS number 65000
1 BGP AS-PATH entries
Neighbor V AS MsgRcvd MsgSent Up/DownTime State
192.168.23.3 4 65000 45 40 0:25:28 ESTABLISHED
Total number of neighbors 1
R2(config)#
R2(config)#
R2(config)# show ip route bgp
IP Routing Table - 2 entries, 7 hidden, 2039 frees
Entries: 0 Connected, 0 Static, 0 RIP, 0 OSPF, 2 BGP
Codes: C - Connected, S - Static, R - RIP, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, B - BGP
* - Candidate default, s - Summary
Timers: Age
B 10.3.3.3/32 [200/0] via 192.168.23.3, GigaEthernet0.0, 0:25:29
B 192.168.3.0/24 [200/0] via 192.168.23.3, GigaEthernet0.0, 0:25:29
R2(config)#
動作確認 (2) BGPからOSPFへの再配送
設定投入
BGPからOSPFへの再配送を設定します。
NEC IXに限らずCisco IOS XEなども同様ですが、デフォルトではiBGPから学習したprefixはIGP(OSPFなど)へ再配送されません。おそらくルーティングループなどを危惧した配慮かと思います。このデフォルト挙動を打ち消し、iBGPをOSPFに再配送するには”redistribute-internal”と呼ばれる設定が必要です。
[R2:IX2015]
router bgp 65000
address-family ipv4 unicast
redistribute-internal
BGPをOSPFへ再配送します。metric-typeは必須設定ではありませんが、デフォルト設定のtype 2よりも、type 1が好きな人をよく見ます。
[R2:IX2015] ip router ospf 1 redistribute bgp 65000 metric-type 1 area 0
動作確認
R1のルーティングテーブルにR3向けprefixが載っている事を確認します。
[R1:VyOS1.4]
admin@R1:~$ show ip route ospf
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
O>* 10.3.3.3/32 [110/2] via 192.168.12.2, eth1, weight 1, 00:12:14
O>* 192.168.3.0/24 [110/2] via 192.168.12.2, eth1, weight 1, 00:12:14
O 192.168.12.0/24 [110/1] is directly connected, eth1, weight 1, 01:24:56
admin@R1:~$
動作確認 (3) OSPFからBGPへの再配送
設定投入
OSPFからBGPへ再配送する設定を入れます。
[R2:IX2015]
router bgp 65000
address-family ipv4 unicast
redistribute ospf 1
再配送されたprefixはnext hopは192.168.12.1です。上記の設定ではnext hopへ疎通不能になりますので、next hopを含むセグメント192.168.12.0/24をadvertiseします。
[R2:IX2015]
router bgp 65000
address-family ipv4 unicast
network 192.168.12.0/24
動作確認
R3のルーティングテーブルにR1向けprefixが載っている事を確認します。
[R3:VyOS1.4]
admin@R3:~$ show ip bgp
BGP table version is 12, local router ID is 10.3.3.3, vrf id 0
Default local pref 100, local AS 65000
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i10.1.1.1/32 192.168.12.1 20 100 0 ?
*> 10.3.3.3/32 0.0.0.0 0 32768 ?
*>i192.168.1.0/24 192.168.12.1 20 100 0 ?
*> 192.168.3.0/24 0.0.0.0 0 32768 ?
*>i192.168.12.0/24 192.168.23.2 1 100 0 i
*> 192.168.23.0/24 0.0.0.0 0 32768 ?
Displayed 6 routes and 6 total paths
admin@R3:~$
admin@R3:~$
admin@R3:~$ show ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
B> 10.1.1.1/32 [200/20] via 192.168.12.1 (recursive), weight 1, 00:01:37
* via 192.168.23.2, eth0, weight 1, 00:01:37
B> 192.168.1.0/24 [200/20] via 192.168.12.1 (recursive), weight 1, 00:01:37
* via 192.168.23.2, eth0, weight 1, 00:01:37
B>* 192.168.12.0/24 [200/1] via 192.168.23.2, eth0, weight 1, 00:01:37
admin@R3:~$
