R2> show ip route 192.168.2.0
Routing entry for192.168.2.0/24
Known via "ospf 10", distance 110, metric 20, type intra area
Last update from 10.0.2.2 on Ethernet1/2, 00:23:31 ago
Routing Descriptor Blocks:
* 10.0.4.2, from 192.168.2.1, 00:23:31 ago, via Ethernet1/4
Route metric is 20, traffic share count is 110.0.3.2, from 192.168.2.1, 00:23:31 ago, via Ethernet1/3
Route metric is 20, traffic share count is 110.0.2.2, from 192.168.2.1, 00:23:31 ago, via Ethernet1/2
Route metric is 20, traffic share count is 110.0.1.2, from 192.168.2.1, 00:23:31 ago, via Ethernet1/1
Route metric is 20, traffic share count is 1
Maximum path はデフォルトで 4 になっており、ECMP なパスが 4 つあれば、4 分散されます。現在の Maximum path 設定は "show ip protocols" で確認できます。
1 2 3 4 5 6 7 8 910111213141516
R2> show ip protocols
Routing Protocol is "ospf 10"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.1.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
0.0.0.0 255.255.255.255 area 0.0.0.0
Reference bandwidth unit is 100 mbps
Passive Interface(s):
Ethernet1/0
Routing Information Sources:
Gateway Distance Last Update
192.168.2.1 11000:26:30
Distance: (default is 110)
Maximum path は最大 16 まで設定できます。 最近の Cisco1812J で試したところ、32path まで設定出来るようでした。
12345
R2(config)# router ospf 10
R2(config-router)# maximum-paths ?
<1-16> Number of paths
R2(config-router)# maximum-paths 3
Maximum path が 3 に設定された為、ルーティングテーブル上に ECMP される経路が 3 つしか表示されなくなりました。
1 2 3 4 5 6 7 8 91011
R2# show ip route 192.168.2.0
Routing entry for192.168.2.0/24
Known via "ospf 10", distance 110, metric 20, type intra area
Last update from 10.0.1.2 on Ethernet1/1, 00:03:04 ago
Routing Descriptor Blocks:
* 10.0.4.2, from 192.168.2.1, 00:03:04 ago, via Ethernet1/4
Route metric is 20, traffic share count is 110.0.3.2, from 192.168.2.1, 00:03:04 ago, via Ethernet1/3
Route metric is 20, traffic share count is 110.0.1.2, from 192.168.2.1, 00:03:04 ago, via Ethernet1/1
Route metric is 20, traffic share count is 1
パケットごとにラウンドロビンされたパスが使われます。送信元や宛先の数に依存せず、パケットは複数のパス上で分散されます。ただし、送信元や宛先が同じパケットも違うパスに分散されてしまう可能性がある為、パケットの追い越し問題を考慮しなければならない VoIP などのトラフィックフローがある場合は設定すべきではありません。
R2# show cef interface Ethernet 1/1
Ethernet1/1 is up (if_number 6)
Corresponding hwidb fast_if_number 6
Corresponding hwidb firstsw->if_number 6
Internet address is 10.0.1.1/30
ICMP redirects are always sent
Per packet load-sharing is disabled
IP unicast RPF check is disabled
Inbound access list is not set
Outbound access list is not set
Hardware idb is Ethernet1/1
Fast switching type1, interface type61
IP CEF switching enabled
IP Fast switching turbo vector
IP Normal CEF switching turbo vector
Input fast flags 0x0, Input fast flags2 0x0, Output fast flags 0x0, Output fast flags2 0x0
ifindex 4(4)
Slot 1 Slot unit 1 Unit 2 VC -1
Transmit limit accumulator 0x0 (0x0)
IP MTU 150
R2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)# interface Ethernet 1/1
R2(config-if)# ip load-sharing ?
per-destination Deterministic distribution
per-packet Random distribution
R2(config-if)# ip load-sharing per-packet
R2(config-if)# end
R2#
R2# show cef interface Ethernet 1/1
Ethernet1/1 is up (if_number 6)
Corresponding hwidb fast_if_number 6
Corresponding hwidb firstsw->if_number 6
Internet address is 10.0.1.1/30
ICMP redirects are always sent
Per packet load-sharing is enabled
IP unicast RPF check is disabled
Inbound access list is not set
Outbound access list is not set
Hardware idb is Ethernet1/1
Fast switching type1, interface type61
IP CEF switching enabled
IP Fast switching turbo vector
IP Normal CEF switching turbo vector
Input fast flags 0x0, Input fast flags2 0x0, Output fast flags 0x0, Output fast flags2 0x0
ifindex 4(4)
Slot 1 Slot unit 1 Unit 2 VC -1
Transmit limit accumulator 0x0 (0x0)
IP MTU 150
R2> show ip cef 192.168.2.0 internal
192.168.2.0/24, version 43, epoch 0, per-destination sharing
0 packets, 0 bytes
via 10.0.4.2, Ethernet1/4, 0 dependencies
traffic share 1
next hop 10.0.4.2, Ethernet1/4
valid adjacency
via 10.0.3.2, Ethernet1/3, 0 dependencies
traffic share 1
next hop 10.0.3.2, Ethernet1/3
valid adjacency
via 10.0.2.2, Ethernet1/2, 0 dependencies
traffic share 1
next hop 10.0.2.2, Ethernet1/2
valid adjacency
via 10.0.1.2, Ethernet1/1, 0 dependencies
traffic share 1
next hop 10.0.1.2, Ethernet1/1
valid adjacency
0 packets, 0 bytes switched through the prefix
tmstats: external 0 packets, 0 bytes
internal 0 packets, 0 bytes
Load distribution: 0123012301230123(refcount 1)
Hash OK Interface Address Packets
1 Y Ethernet1/4 10.0.4.2 02 Y Ethernet1/3 10.0.3.2 03 Y Ethernet1/2 10.0.2.2 04 Y Ethernet1/1 10.0.1.2 05 Y Ethernet1/4 10.0.4.2 06 Y Ethernet1/3 10.0.3.2 07 Y Ethernet1/2 10.0.2.2 08 Y Ethernet1/1 10.0.1.2 09 Y Ethernet1/4 10.0.4.2 010 Y Ethernet1/3 10.0.3.2 011 Y Ethernet1/2 10.0.2.2 012 Y Ethernet1/1 10.0.1.2 013 Y Ethernet1/4 10.0.4.2 785714 Y Ethernet1/3 10.0.3.2 015 Y Ethernet1/2 10.0.2.2 016 Y Ethernet1/1 10.0.1.2 0
refcount 6
R2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)# router ospf 10
R2(config-router)# maximum-paths 3
R2(config-router)# end
R2#
R2# show ip cef 192.168.2.0 internal
192.168.2.0/24, version 44, epoch 0, per-destination sharing
0 packets, 0 bytes
via 10.0.4.2, Ethernet1/4, 0 dependencies
traffic share 1
next hop 10.0.4.2, Ethernet1/4
valid adjacency
via 10.0.3.2, Ethernet1/3, 0 dependencies
traffic share 1
next hop 10.0.3.2, Ethernet1/3
valid adjacency
via 10.0.1.2, Ethernet1/1, 0 dependencies
traffic share 1
next hop 10.0.1.2, Ethernet1/1
valid adjacency
0 packets, 0 bytes switched through the prefix
tmstats: external 0 packets, 0 bytes
internal 0 packets, 0 bytes
Load distribution: 012012012012012(refcount 1)
Hash OK Interface Address Packets
1 Y Ethernet1/4 10.0.4.2 02 Y Ethernet1/3 10.0.3.2 03 Y Ethernet1/1 10.0.1.2 04 Y Ethernet1/4 10.0.4.2 05 Y Ethernet1/3 10.0.3.2 06 Y Ethernet1/1 10.0.1.2 07 Y Ethernet1/4 10.0.4.2 08 Y Ethernet1/3 10.0.3.2 09 Y Ethernet1/1 10.0.1.2 010 Y Ethernet1/4 10.0.4.2 011 Y Ethernet1/3 10.0.3.2 012 Y Ethernet1/1 10.0.1.2 013 Y Ethernet1/4 10.0.4.2 014 Y Ethernet1/3 10.0.3.2 015 Y Ethernet1/1 10.0.1.2 0
refcount 6
R2# show ip cef
%CEF not running
Prefix Next Hop Interface
CEF を有効化するには "ip cef" を設定します。"show ip cef" で確認した際、「%CEF not running」と表示されず、経路情報が表示されれば CEF は有効化されています。
1 2 3 4 5 6 7 8 910
R2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)# ip cef
R2(config)# end
R2#
R2# show ip cef
Prefix Next Hop Interface
0.0.0.0/0 drop Null0 (default route handler entry)0.0.0.0/32 receive
10.0.1.0/30 attached Ethernet1/1
R2# show cef interface e1/1
Ethernet1/1 is up (if_number 6)
Corresponding hwidb fast_if_number 6
Corresponding hwidb firstsw->if_number 6
Internet address is 10.0.1.1/30
ICMP redirects are always sent
Per packet load-sharing is disabled
!--- パケット単位の分散が無効化されているので宛先単位設定になっています
IP unicast RPF check is disabled
Inbound access list is not set
Outbound access list is not set
Hardware idb is Ethernet1/1
Fast switching type1, interface type61
IP CEF switching enabled
!--- このインターフェイスで CEF は有効化されています
IP Fast switching turbo vector
IP Normal CEF switching turbo vector
Input fast flags 0x0, Input fast flags2 0x0, Output fast flags 0x0, Output fast flags2 0x0
ifindex 4(4)
Slot 1 Slot unit 1 Unit 2 VC -1
Transmit limit accumulator 0x0 (0x0)
IP MTU 1500
RIB(Routing Information Base)はルーティングテーブルのことです。RIB に経路がインストールされていることを確認します。
1 2 3 4 5 6 7 8 910111213
R2# show ip route 192.168.2.0
Routing entry for192.168.2.0/24
Known via "ospf 10", distance 110, metric 20, type intra area
Last update from 10.0.2.2 on Ethernet1/2, 03:02:26 ago
Routing Descriptor Blocks:
* 10.0.4.2, from 192.168.2.1, 03:02:26 ago, via Ethernet1/4
Route metric is 20, traffic share count is 110.0.3.2, from 192.168.2.1, 03:02:26 ago, via Ethernet1/3
Route metric is 20, traffic share count is 110.0.2.2, from 192.168.2.1, 03:02:26 ago, via Ethernet1/2
Route metric is 20, traffic share count is 110.0.1.2, from 192.168.2.1, 03:02:26 ago, via Ethernet1/1
Route metric is 20, traffic share count is 1
R2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)# ip cef accounting ?
non-recursive Enable accounting for traffic through non-recursive prefixes
per-prefix Enable per prefix accounting
prefix-length Enable prefix length accounting
R2(config)# ip cef accounting load-balance-hash
R2(config)#
R2# show ip cef 192.168.2.0 internal
192.168.2.0/24, version 32, epoch 0, per-destination sharing
0 packets, 0 bytes
via 10.0.4.2, Ethernet1/4, 0 dependencies
traffic share 1
next hop 10.0.4.2, Ethernet1/4
valid adjacency
via 10.0.3.2, Ethernet1/3, 0 dependencies
traffic share 1
next hop 10.0.3.2, Ethernet1/3
valid adjacency
via 10.0.2.2, Ethernet1/2, 0 dependencies
traffic share 1
next hop 10.0.2.2, Ethernet1/2
valid adjacency
via 10.0.1.2, Ethernet1/1, 0 dependencies
traffic share 1
next hop 10.0.1.2, Ethernet1/1
valid adjacency
0 packets, 0 bytes switched through the prefix
tmstats: external 0 packets, 0 bytes
internal 0 packets, 0 bytes
Load distribution: 0123012301230123(refcount 1)
Hash OK Interface Address Packets
1 Y Ethernet1/4 10.0.4.2 02 Y Ethernet1/3 10.0.3.2 03 Y Ethernet1/2 10.0.2.2 04 Y Ethernet1/1 10.0.1.2 05 Y Ethernet1/4 10.0.4.2 06 Y Ethernet1/3 10.0.3.2 07 Y Ethernet1/2 10.0.2.2 08 Y Ethernet1/1 10.0.1.2 09 Y Ethernet1/4 10.0.4.2 010 Y Ethernet1/3 10.0.3.2 011 Y Ethernet1/2 10.0.2.2 012 Y Ethernet1/1 10.0.1.2 013 Y Ethernet1/4 10.0.4.2 10014 Y Ethernet1/3 10.0.3.2 015 Y Ethernet1/2 10.0.2.2 016 Y Ethernet1/1 10.0.1.2 0
refcount 6
統計情報をリセットできる clear コマンドは存在しないようですが、トラフィックフローに関連するインターフェイスを "shutdown" や "no shutdown" し、ハッシュバケットの使われ方が再計算されると統計情報はクリアされるようです。
R2# show interfaces | include Ethernet1/[1-4]|second
Ethernet1/1 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 0 bits/sec, 0 packets/sec
Ethernet1/2 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 0 bits/sec, 0 packets/sec
Ethernet1/3 is up, line protocol is up
30 second input rate 4000 bits/sec, 5 packets/sec
30 second output rate 0 bits/sec, 0 packets/sec
Ethernet1/4 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 4000 bits/sec, 5 packets/sec
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/4 (next hop 10.0.4.2)
Bucket 12 from 16, total 4 path
ここでは「ゼロ始まり」でハッシュバケットが表示される為、「Bucket12」と表示されている、ということは "show ip cef ''宛先アドレス'' internal" で表示されるハッシュバケットのうち 13 番が使われることになります。
R3# show ip cef exact-route 192.168.2.10 192.168.1.10 internal
192.168.2.10 -> 192.168.1.10 : Ethernet1/3 (next hop 10.0.3.1)
Bucket 1 from 16, total 4 paths
R2# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)# interface Ethernet1/1
R2(config-if)# ip load-sharing per-packet
R2(config-if)#
R2(config-if)# interface Ethernet1/2
R2(config-if)# ip load-sharing per-packet
R2(config-if)#
R2(config-if)# interface Ethernet1/3
R2(config-if)# ip load-sharing per-packet
R2(config-if)#
R2(config-if)# interface Ethernet1/4
R2(config-if)# ip load-sharing per-packet
"show ip cef ''宛先アドレス'' internal" で該当のトラフィックフローがパケット単位に変更されたことを確認します。
R2# show ip cef 192.168.2.0 internal
192.168.2.0/24, version 40, epoch 0, per-packet sharing
!--- パケット単位に変更されています
0 packets, 0 bytes
via 10.0.4.2, Ethernet1/4, 0 dependencies
traffic share 1, current path
next hop 10.0.4.2, Ethernet1/4
valid adjacency
via 10.0.3.2, Ethernet1/3, 0 dependencies
traffic share 1
next hop 10.0.3.2, Ethernet1/3
valid adjacency
via 10.0.2.2, Ethernet1/2, 0 dependencies
traffic share 1
next hop 10.0.2.2, Ethernet1/2
valid adjacency
via 10.0.1.2, Ethernet1/1, 0 dependencies
traffic share 1
next hop 10.0.1.2, Ethernet1/1
valid adjacency
0 packets, 0 bytes switched through the prefix
tmstats: external 0 packets, 0 bytes
internal 0 packets, 0 bytes
Load distribution: 0123012301230123(refcount 1)
Hash OK Interface Address Packets
1 Y Ethernet1/4 10.0.4.2 02 Y Ethernet1/3 10.0.3.2 03 Y Ethernet1/2 10.0.2.2 04 Y Ethernet1/1 10.0.1.2 05 Y Ethernet1/4 10.0.4.2 06 Y Ethernet1/3 10.0.3.2 07 Y Ethernet1/2 10.0.2.2 08 Y Ethernet1/1 10.0.1.2 09 Y Ethernet1/4 10.0.4.2 010 Y Ethernet1/3 10.0.3.2 011 Y Ethernet1/2 10.0.2.2 012 Y Ethernet1/1 10.0.1.2 013 Y Ethernet1/4 10.0.4.2 014 Y Ethernet1/3 10.0.3.2 015 Y Ethernet1/2 10.0.2.2 016 Y Ethernet1/1 10.0.1.2 0
refcount 6
R2# show interfaces | include Ethernet1/[1-4]|second
Ethernet1/1 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 6000 bits/sec, 6 packets/sec
Ethernet1/2 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 6000 bits/sec, 7 packets/sec
Ethernet1/3 is up, line protocol is up
30 second input rate 17000 bits/sec, 19 packets/sec
30 second output rate 6000 bits/sec, 6 packets/sec
Ethernet1/4 is up, line protocol is up
30 second input rate 0 bits/sec, 0 packets/sec
30 second output rate 6000 bits/sec, 7 packets/sec
Out トラフィックが 4 つの ECMP パスで均等に分散されているのが分かります(R3 では何も変更しておらず、宛先単位のままである為、戻りパケットは分散されず、相変わらず Ethernet1/3 に偏っているのが分かります)。ハッシュバケットの状態も確認してみます。
R2# show ip cef 192.168.2.0 internal
192.168.2.0/24, version 40, epoch 0, per-packet sharing
0 packets, 0 bytes
via 10.0.4.2, Ethernet1/4, 0 dependencies
traffic share 1
next hop 10.0.4.2, Ethernet1/4
valid adjacency
via 10.0.3.2, Ethernet1/3, 0 dependencies
traffic share 1, current path
next hop 10.0.3.2, Ethernet1/3
valid adjacency
via 10.0.2.2, Ethernet1/2, 0 dependencies
traffic share 1
next hop 10.0.2.2, Ethernet1/2
valid adjacency
via 10.0.1.2, Ethernet1/1, 0 dependencies
traffic share 1
next hop 10.0.1.2, Ethernet1/1
valid adjacency
0 packets, 0 bytes switched through the prefix
tmstats: external 0 packets, 0 bytes
internal 0 packets, 0 bytes
Load distribution: 0123012301230123(refcount 1)
Hash OK Interface Address Packets
1 Y Ethernet1/4 10.0.4.2 152 Y Ethernet1/3 10.0.3.2 153 Y Ethernet1/2 10.0.2.2 154 Y Ethernet1/1 10.0.1.2 155 Y Ethernet1/4 10.0.4.2 146 Y Ethernet1/3 10.0.3.2 147 Y Ethernet1/2 10.0.2.2 148 Y Ethernet1/1 10.0.1.2 149 Y Ethernet1/4 10.0.4.2 1410 Y Ethernet1/3 10.0.3.2 1411 Y Ethernet1/2 10.0.2.2 1412 Y Ethernet1/1 10.0.1.2 1413 Y Ethernet1/4 10.0.4.2 1414 Y Ethernet1/3 10.0.3.2 1415 Y Ethernet1/2 10.0.2.2 1416 Y Ethernet1/1 10.0.1.2 14
refcount 6
"show ip cef exact-route ''送信元アドレス'' ''宛先アドレス'' internal" で次に使われるハッシュバケットを確認しても、次に使われるハッシュバケットが変化していることが分かります(手動で実行している為、連番にはなりません)。
1 2 3 4 5 6 7 8 9101112131415
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/3 (next hop 10.0.3.2)
Bucket 13 from 16, total 4 paths
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/3 (next hop 10.0.3.2)
Bucket 9 from 16, total 4 paths
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/4 (next hop 10.0.4.2)
Bucket 8 from 16, total 4 paths
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/3 (next hop 10.0.3.2)
Bucket 9 from 16, total 4 paths
R2# show ip cef exact-route 192.168.1.10 192.168.2.10 internal
192.168.1.10 -> 192.168.2.10 : Ethernet1/3 (next hop 10.0.3.2)
Bucket 13 from 16, total 4 path