Enhanced Interior Gateway Routing Protocol (EIGRP) 增强型内部网关路由协定

前言

Enhanced Interior Gateway Routing Protocol (EIGRP) 属於 Hybrid Routing Protocol (混合型),包含了 Distance-Vector 与 Link-State 的特性。就像 Link-State 一样,EIGRP 会把相邻的 Router 成为 Neighbor,定时检查他们的状态,而 EIGRP 源用了 Distance-Vector 的概念去计算 Network 的 distance。留意 EIGRP 是 Cisco 专属的 Protocol,只有 Cisco 产品才能执行 EIGRP。

Neighbor

入门第一件事就是学学怎样设定 Router 成为 EIGRP Neighbor,现在为以下这个网络做一个最简单的 EIGRP 设定。

eigrp

首先把 IP Address 设定好:

hostname R1
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
hostname R2
!
interface Ethernet0/0
 ip address 192.168.23.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.12.2 255.255.255.0
hostname R3
!
interface Ethernet0/1
 ip address 192.168.23.3 255.255.255.0

要设定 EIGRP 的指令极其简单,先用 router eigrp <AS no> 进入 EIGRP 设定,然後输入要参与 EIGRP 的 network。而 auto-summary 是预设的,在讨论 Summary 的部份会再详细说明。另外需要注意的是,在同一个 AS 内的 EIGRP Router ,所有 AS Number 必需相同。

hostname R1
!
router eigrp 1
 network 192.168.12.0
 auto-summary
hostname R2
!
router eigrp 1
 network 192.168.12.0
 network 192.168.23.0
 auto-summary
hostname R3
!
router eigrp 1
 network 192.168.23.0
 auto-summary

预设情况下,Router 之间是利用 Multicast 沟通的。如果网络连线不支缓 Multicast 或因为某些原因 Multicast 未能顺利传送的话,Router 就无法成为 Neighbor。遇到这些情况,我们使用 Neighbor 指令利用 Unicast 去传送 EIGRP 封包。例如 R1 与 R2 之间使用 Unicast,设定如下:

R1(config)#router eigrp 1
R1(config-router)#neighbor 192.168.12.2 Ethernet0/0
R2(config)#router eigrp 1
R2(config-router)#neighbor 192.168.12.1 Ethernet0/1

想确认一下有没有成功建立 Neighbor,可以用 show ip eigrp neighbors 指令。

R2#show ip eigrp neighbors
IP-EIGRP neighbors for process 1
H   Address                 Interface       Hold Uptime   SRTT   RTO  Q  Seq
                                            (sec)         (ms)       Cnt Num
0   192.168.12.1            Et0/1             12 00:08:02  297  1782  0  9
1   192.168.23.3            Et0/0             13 01:07:01   44   264  0  5

H

这只不过是一个流水号,由 0 开始数,没有特别意思,然而为什麽叫 H 呢?可能是 Hop 的意思吧,我也不太肯定。

Address

就是 Neighbor 的 IP Address。

Interface

Neighbor 的 Hello Message 是从那个 Interface 收到的。

Holdtime

EIGRP 有两个 Timer,分别是 Hello Timer 及 Hold Timer,预设值 Hello 是 5 秒,Hold 是 15 秒,即是说 EIGRP Router 会每隔 5 秒传送 Hello Message,如果收到的话就继续维持 Neighbor 的关系,一但过了 15 秒都没收到 Hello 的话,就中断 Neighbor 的关系。所以 Holdtime 会从 15 秒开始倒数,直到收到 Hello 後又重设成 15 秒。Hello Timer 和 Hold Timer 是可以在 Interface 下更改的,指令如下:

R2(config)#int ethernet 0/0
R2(config-if)#ip hello-interval eigrp ?
  <1-65535>  Autonomous system number

R2(config-if)#ip hello-interval eigrp 1 ?
  <1-65535>  Seconds between hello transmissions

R2(config-if)#ip hello-interval eigrp 1 10
R2(config-if)#
R2(config-if)#ip hold-time eigrp ?
  <1-65535>  Autonomous system number

R2(config-if)#ip hold-time eigrp 1 ?
  <1-65535>  Seconds before neighbor is considered down

R2(config-if)#ip hold-time eigrp 1 30

记得两只成为 Neighbor 的 Router 也要更改,不过,就算两只 Router 的 Timer 不相同,它们也可成为 Neighbor!不过习惯上还是把它们设成一样吧。设定好後 Reset Neighbor,观察 Neighbor Table,发现 Timer 由 30 开始倒数了。

R2#clear ip eigrp 1 neighbors
R2#
R2#show ip eigrp neighbors
IP-EIGRP neighbors for process 1
H   Address                 Interface       Hold Uptime   SRTT   RTO  Q  Seq
                                            (sec)         (ms)       Cnt Num
1   192.168.23.3            Et0/0             29 00:00:00   67   402  0  22
0   192.168.12.1            Et0/1             14 00:00:04   49   294  0  24
R2#

Uptime

与这 Router 成为 Neighbor 多久了。

SRTT

全写是 Smoothed round-trip time,Router 在收到 EIGRP packet 後都会回传一个 ACK (acknowledgment)。SRTT 即 Router 送出 EIGRP packet 然後收到对方回覆 ACK 的时间。单位是 milliseconds。

RTO

全写是 Retransmission Timeout,即是说如果送出 EIGRP packet 後没有收到 ACK,要等多少时再重新传送呢?RTO 是用 SRTT 计算出来的,不能设定。单位是 milliseconds。

Q Cnt

即 Query Count,意思是有多少 EIGRP packet 在排队等候传送。0 是正常的,如果数字越来越大的话,则代表 EIGRP packet 都传不出去,要检查 Interface 是否出问题了。

Seq Num

最後收到的 EIGRP Packet 的 Sequence Number,这个数字应该是越来越大的。

Authentication

基於保安理由,我们可以在 EIGRP Neighbor 的 Interface 之间设密码,这样可以避免有 Router 假扮成 Neighbor 来偷取 Route 资讯。设密码有两个步骤,首先在两只 Router 分别设定 Key Chain。

R1(config)# key chain MyChain
R1(config-keychain)# key 1
R1(config-keychain-key)# key-string MyPassword
R2(config)# key chain MyChain
R2(config-keychain)# key 1
R2(config-keychain-key)# key-string MyPassword

第二步是在 Interface 设定 Key Chain 和 MD5 encryption。

R1(config)# interface ethernet 0/0
R1(config-if)# ip authentication key-chain eigrp 1 MyChain
R1(config-if)# ip authentication mode eigrp 1 md5
R2(config)# interface ethernet 0/1
R2(config-if)# ip authentication key-chain eigrp 1 MyChain
R2(config-if)# ip authentication mode eigrp 1 md5

用 show ip eigrp interfaces detail 可以查看 Authentication 资讯。

R1#show ip eigrp interfaces detail
IP-EIGRP interfaces for process 1

                        Xmit Queue   Mean   Pacing Time   Multicast    Pending
Interface        Peers  Un/Reliable  SRTT   Un/Reliable   Flow Timer   Routes
Et0/0              1        0/0        88       0/2          436           0
  Hello interval is 5 sec
  Next xmit serial <none>
  Un/reliable mcasts: 0/12  Un/reliable ucasts: 22/32
  Mcast exceptions: 11  CR packets: 11  ACKs suppressed: 0
  Retransmissions sent: 12  Out-of-sequence rcvd: 0
  Authentication mode is md5,  key-chain is "MyChain"
  Use multicast

Metric

每种 Routing Protocol 都有自己一套计算 Metric 的方法,EIGRP 又怎样计算呢?EIGRP 的 Metric 有一条看起来颇复杂的公式:

Metric = [K1 *  BW * 256 + (K2 * BW) / (256-load) + K3 * delay *256] *
[K5 / (reliability + K4)]

where BW = 10^7 Kbit / interface bandwidth (Kbit)
delay = interface delay (usec) / 10

真的有够复杂!不用担心,因为预设 K1=1, K2=0, K3=1, K4=0, K5=0,这些叫做 K Value,而我们通常会使用预设值,很少会更改 K Value,所以公式会被简化成:

Metric = (BW * 256 + delay * 256)
= (BW + delay) * 256

where BW = 10^7 Kbit / interface bandwidth (Kbit)
delay = interface delay (usec) / 10

这样就简单得多了,不过特别要说的是,所谓 Bandwidth 是计算整条 path 里面 bandwidth 最小的一段,而 delay 则是每一段的总和,现在会用以下网络作例子来示范怎样计算 Metric。R3 的 L0 亦会参与 EIGRP,假设 IP Address 与 EIGRP 都已经设定好。

eigrp

先到 R3,用 show ip eigrp topology 查看 EIGRP Topology Table。FD 所显示的数值就是 Metric,可见在 R3 要到达 192.168.34.0 / 24 这个 Network,Metric 是 128256,怎样计呢?

R3#show ip eigrp 1 topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.34.3)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.34.0/24, 1 successors, FD is 128256
        via Connected, Loopback0
P 192.168.12.0/24, 1 successors, FD is 307200
        via 192.168.23.2 (307200/281600), Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1

引用刚刚说过的公式:(BW + delay) * 256。所以要先查看 L0 这个 Interface 的 bandwidth 和 delay。

R3#show interfaces l0 | include BW
  MTU 1514 bytes, BW 8000000 Kbit, DLY 5000 usec,
  • BW = 10^7 / interface bandwidth = 10^7 / 8000000 = 1.25 = 1 (舍去小数)
  • Delay = interface delay / 10 = 5000 / 10 = 500
  • Metric = (1 + 500) * 256 = 128256

然後在 R2 见到 192.168.34.0 / 24 的 Metric 是 409600,为什麽呢?

R2#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.2)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.34.0/24, 1 successors, FD is 409600
        via 192.168.23.3 (409600/128256), Ethernet0/0
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0

先检查 R2 ethernet0/0 的 Bandwidth 和 Delay。

R2#show interfaces ethernet 0/0 | include BW
  MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,

从 R2 的 eth0/0 到 R3,然後从 R3 的 L0 到达 192.168.34.0 / 24,Bandwidth 最小的一段是 R2 的 eth0/0,所以 Interface bandwidth 是 10000K。至於 Delay 是计算总和的,所以 Interface Delay 是 5000 + 1000 = 6000。

  • BW = 10^7 / interface bandwidth = 10^7 / 10000 = 1000
  • Delay = interface delay / 10 = 6000 / 10 = 600
  • Metric = (1000 + 600) * 256 = 409600

至於 R1 我就不计算了,留待读者们自己试试吧。

R1#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.12.1)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.34.0/24, 1 successors, FD is 435200
        via 192.168.12.2 (435200/409600), Ethernet0/0
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.23.0/24, 1 successors, FD is 307200
        via 192.168.12.2 (307200/281600), Ethernet0/0

刚才说过 K Values 的预值是 K1=1, K2=0, K3=1, K4=0, K5=0,这是可以更改的。指令如下:

R2(config)#router eigrp 1
R2(config-router)#metric weights 0 5 2 1 10 1

第一个数字是 Type,填 0 便可以,其後 5 个数字分别是 K1 至 K5 的值。

路径选择

学会了计算 Metric 之後,现在要学习一个 EIGRP 里面很重要的概念,就是路径的选择。这个部份首先要灌输 Feasible Distance 及 Advertised Distance 两个名词。以下面这个网络作为例子:

eigrp

Advertised Distance (AD) 是 Neighbor 告讯我他要去目的地的 Metric。因此:

  • R2 收到 R3 告诉它,R3 要到达目的地的 Metric 是 100,所以 R2 去目的地的 AD 是 100。
  • R1 收到 R2 告诉它,R2 要到达目的地的 Metric 是 300 (= 100 + 200),所以 R1 去目的地的 AD 是 300。

Distance

Distance 是 Neighbor 给我的 AD 加上我要到达这个 Neighbor 的 Metric。

  • R2 收到 R3 告诉它要到达目的地的 AD 是 100,而 R2 要到 R3 需要 200,因此 R2 到达目的地的 Metric 是 300,即 Distance 是 300。
  • R1 收到 R2 告诉它要到达目的地的 AD 是 300,而 R1 要到 R2 需要 300,因此 R1 到达目的地的 Metric 是 600,即 Distance 是 600。

Feasible Distance (FD)

如果有多条 Path 能够到达目的地,当中 Distance 最小的那条 Route ,它的 Distance 就是 Feasible Distance (FD)。

如果有多条路径可以到达目的地,EIGRP 可以利用 AD 和 FD 决定 Successor 和 Feasible Successor。Successor 可以理解为 best path,EIGRP 会把 Distance 最小的设为 Successor 并放进 Route Table,Feasible Successor 则是用作後备的 Successor,所有 AD 少於 FD 的 Path 会设为 Feasible Successor,当发现 Successor 出了问题,EIGRP 会立刻用 Feasible Successor 顶上。

接下来,我们用一个有多条路径的网络来解释一下 Successor 的选择。假设所有 IP Address 和 EIGRP 已经设定好。针对 R1 要到达 192.168.56.0 / 24 来作实验。

eigrp

先在 R1 看看 Topology Table 和 Route Table。要到达 192.168.56.0 / 24 这个 network ,R1 有 3 条 path 可以选择,分别是 192.168.12.2,192.168.13.3 和 192.168.14.4 ,括号内的数是分别是这条 Route 的 Distance 和 AD (前面较大的是 Distance,後面较小的是 AD)。由於三条 Route Distance 都相同,所以 EIGRP 把 3 条 Route 都选为 Successors,并放进 Route Table 之中,这时要到目的地的 Traffic 会 Load Balance 地使用这 3 条 Route。

R1#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.14.1)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.45.0/24, 1 successors, FD is 307200
        via 192.168.14.4 (307200/281600), Ethernet0/2
P 192.168.35.0/24, 1 successors, FD is 307200
        via 192.168.13.3 (307200/281600), Ethernet0/1
P 192.168.56.0/24, 3 successors, FD is 435200
        via 192.168.12.2 (435200/409600), Ethernet0/0
        via 192.168.13.3 (435200/409600), Ethernet0/1
        via 192.168.14.4 (435200/409600), Ethernet0/2
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.13.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 192.168.14.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/2
P 192.168.25.0/24, 1 successors, FD is 307200
        via 192.168.12.2 (307200/281600), Ethernet0/0
R1#
R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/435200] via 192.168.14.4, 00:00:56, Ethernet0/2
                     [90/435200] via 192.168.13.3, 00:00:56, Ethernet0/1
                     [90/435200] via 192.168.12.2, 00:00:56, Ethernet0/0

现在我们做一些调整,把 R3 和 R4 E0/1 的 Delay 调高,这样两条路线的 Distance 和 AD 都会改变。

R3(config)#interface ethernet 0/1
R3(config-if)#delay 110
R4(config)#interface ethernet 0/1
R4(config-if)#delay 250

在回到 R1 看看 Topology Table,发现经 R3 的 Path Distance 和 AD 都增加了,现在只有 192.168.12.2 这 1 条 successor。而 192.168.13.3 仍然保留在 Topology Table 之中因为它的 AD 比 FD 小,所以成为 Feasible Successor。至 192.168.14.4 因为 AD 比 FD 大,Feasible Successor 都做不成,就被移除了。但如果想看看它的 Distance 和 AD,还是有方法的,可以使用 show ip eigrp topology all-links。最後,EIGRP 只会把 Successor 放进 Route Table 之中。

R1#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.14.1)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.45.0/24, 1 successors, FD is 332800
        via 192.168.12.2 (332800/307200), Ethernet0/0
        via 192.168.14.4 (345600/320000), Ethernet0/2
        via 192.168.13.3 (335360/309760), Ethernet0/1
P 192.168.35.0/24, 1 successors, FD is 307200
        via 192.168.13.3 (309760/284160), Ethernet0/1
P 192.168.56.0/24, 1 successors, FD is 435200
        via 192.168.12.2 (435200/409600), Ethernet0/0
        via 192.168.13.3 (437760/412160), Ethernet0/1
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.13.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 192.168.14.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/2
P 192.168.25.0/24, 1 successors, FD is 307200
        via 192.168.12.2 (307200/281600), Ethernet0/0
R1#
R1#show ip eigrp topology all-links
IP-EIGRP Topology Table for AS(1)/ID(192.168.14.1)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.45.0/24, 1 successors, FD is 332800, serno 54
        via 192.168.12.2 (332800/307200), Ethernet0/0
        via 192.168.14.4 (345600/320000), Ethernet0/2
        via 192.168.13.3 (335360/309760), Ethernet0/1
P 192.168.35.0/24, 1 successors, FD is 307200, serno 51
        via 192.168.13.3 (309760/284160), Ethernet0/1
        via 192.168.12.2 (332800/307200), Ethernet0/0
P 192.168.56.0/24, 1 successors, FD is 435200, serno 56
        via 192.168.12.2 (435200/409600), Ethernet0/0
        via 192.168.14.4 (473600/448000), Ethernet0/2
        via 192.168.13.3 (437760/412160), Ethernet0/1
P 192.168.12.0/24, 1 successors, FD is 281600, serno 1
        via Connected, Ethernet0/0
P 192.168.13.0/24, 1 successors, FD is 281600, serno 2
        via Connected, Ethernet0/1
P 192.168.14.0/24, 1 successors, FD is 281600, serno 3
        via Connected, Ethernet0/2
P 192.168.25.0/24, 1 successors, FD is 307200, serno 26
R1#
R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/435200] via 192.168.12.2, 00:05:34, Ethernet0/0

如果 192.168.12.2 的 path 不通,Feasible Successor 192.168.13.3 就会立刻顶上成为 Successor,现在测试一下,把 R2 的 eth0/1 关掉。

R2(config)#int ethernet 0/0
R2(config-if)#shutdown

Route Table 变成使用 192.168.13.3 了。

R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/437760] via 192.168.13.3, 00:00:00, Ethernet0/1

如果把 R3 的 Eth0/1 都关掉又会发生什麽事呢?由於已经没有 Feasible Successor 了,R1 会发出 Query Message 询问连接的 Neighbor 有没有 192.168.56.0 / 24 的方法,当然 R4 会回覆,这样,R1 就用了 192.168.14.4 作为 到 192.168.56.0 / 24 的 Next Hop 了。

R3(config)#int ethernet 0/0
R3(config-if)#shutdown
R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/473600] via 192.168.14.4, 00:04:52, Ethernet0/2

Variance

EIGRP 容许 Metric 不同的 Route 来做 Load Balancing,主要需要调校 Variance 这个参数。Variance 是一个倍数,意思是容许 FD 的多少倍以下 Distance 的 Route 进行 Load Balance,文字较难表达,请看以下例子。现有 3 条路径可到达 192.168.56.0 / 24。

R1#show ip eigrp topology | begin 192.168.56.0
P 192.168.56.0/24, 1 successors, FD is 435200
        via 192.168.12.2 (435200/409600), Ethernet0/0
        via 192.168.13.3 (768000/409600), Ethernet0/1
        via 192.168.14.4 (1177600/409600), Ethernet0/2

<--output omitted-->

由於 Variance 预设值为 1,因此只有 Distance 435200 这条可以进入 Route Table。

R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/435200] via 192.168.12.2, 00:00:17, Ethernet0/0

现在把 Variance 设为 2,由於 FD = 435200,FD * variance = 435200 * 2 = 870400,因此凡是 Distance 少於 870400 的 Route 都可以进入 Route Table 了。

R1(config)#router eigrp 1
R1(config-router)#variance 2
R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/768000] via 192.168.13.3, 00:01:25, Ethernet0/1
                     [90/435200] via 192.168.12.2, 00:01:25, Ethernet0/0

如果改成 3 呢?435200 * 3 = 1305600,全部 3 条 Route 都可以进入 Route Table。

R1(config)#router eigrp 1
R1(config-router)#variance 3
R1#show ip route | begin 192.168.56.0
D    192.168.56.0/24 [90/1177600] via 192.168.14.4, 00:00:05, Ethernet0/2
                     [90/768000] via 192.168.13.3, 00:00:05, Ethernet0/1
                     [90/435200] via 192.168.12.2, 00:00:05, Ethernet0/0

留意 EIGRP 的 Load Balancing 并不是平均分配的,而是按 Metric 的反比例分配,由於 192.168.12.2 Metric 最少,它会得到最多 Traffic,192.168.13.3 第二,而 Metric 最大的 192.168.14.4 则获分配最少 Traffic。

Summarization

很多时候我们会把 EIGRP 的 auto summary 关掉,其实 summary 并非什麽洪水猛兽,若果使用得宜的话,可以把多条 Route 组合成一条,减少 Route Table 中 Route 的数目。现在使用下图作例子,实验开始时,我们先把 auto summary 关掉。

eigrp

各 Router 设定如下:

hostname R1
!
interface Ethernet0/0
 ip address 172.16.13.1 255.255.255.0
!
router eigrp 1
 network 172.16.13.0 0.0.0.255
 no auto-summary
hostname R2
!
interface Ethernet0/0
 ip address 172.16.23.2 255.255.255.0
!
router eigrp 1
 network 172.16.23.0 0.0.0.255
 no auto-summary
hostname R3
!
interface Ethernet0/0
 ip address 172.16.13.3 255.255.255.0
!
interface Ethernet0/1
 ip address 172.16.23.3 255.255.255.0
!
interface Ethernet0/2
 ip address 192.168.34.3 255.255.255.0
!
router eigrp 1
 network 172.16.13.0 0.0.0.255
 network 172.16.23.0 0.0.0.255
 network 192.168.34.0
 no auto-summary
hostname R4
!
interface Ethernet0/0
 ip address 192.168.34.4 255.255.255.0
!
router eigrp 1
 network 192.168.34.0
 no auto-summary

看看 R3 和 R4 的 Route Table,留意 R4 的 Route Table 中,172.16.23.0 与 172.16.13.0 两个 Network 是分开两条 Route 显示。

R3#show ip route | begin Gateway
Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.23.0 is directly connected, Ethernet0/1
C       172.16.13.0 is directly connected, Ethernet0/0
C    192.168.34.0/24 is directly connected, Ethernet0/2
R4#show ip route | begin Gateway
Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 2 subnets
D       172.16.23.0 [90/307200] via 192.168.34.3, 00:01:34, Ethernet0/0
D       172.16.13.0 [90/307200] via 192.168.34.3, 00:01:34, Ethernet0/0
C    192.168.34.0/24 is directly connected, Ethernet0/0

现在试试用 Manual 方法把这 2 条 Route Summize 成为 1 条:

R3(config)#int ethernet 0/2
R3(config-if)#ip summary-address eigrp 1 172.16.0.0 255.255.224.0

输入 summary 指令後发现 R3 增加了一条 Summary Route 指向 Null0,作用是防止 Routing Loop,有了这条 Route,所有 Destination 是 172.16.0.0/19 的 packet 如果找不到出路的话就会被指向 Null 0 Drop 掉了。

R3#show ip route | begin Gateway
Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C       172.16.23.0/24 is directly connected, Ethernet0/1
C       172.16.13.0/24 is directly connected, Ethernet0/0
D       172.16.0.0/19 is a summary, 00:00:28, Null0
C    192.168.34.0/24 is directly connected, Ethernet0/2

而 R4 就收到 R3 传来的 Summary Route 172.16.0.0 / 19,本来 2 条 Route 变成 1 条了。

R4#show ip route | begin Gateway
Gateway of last resort is not set

     172.16.0.0/19 is subnetted, 1 subnets
D       172.16.0.0 [90/307200] via 192.168.34.3, 00:00:50, Ethernet0/0
C    192.168.34.0/24 is directly connected, Ethernet0/0

如果用 Auto Summary 情况又会怎样呢?先在 R3 把刚才的 summary-address no 掉,然後用 auto-summary。

R3(config-if)#no ip summary-address eigrp 1 172.16.0.0 255.255.224.0
R3(config-if)#
R3(config-if)#router eigrp 1
R3(config-router)#auto-summary

EIGRP 自己选择用了 prefix /16 来做 Summary,为什麽是 16 呢?原来 Auto Summary 会按 IP 的 Class 来定 prefix,Class A 就用 /8,Class B 就用 /16,Class C 当然就是 /24 了。172.16.0.0 是 Class B,所以用了 /16。

R3#show ip route | begin Gateway
Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C       172.16.23.0/24 is directly connected, Ethernet0/1
C       172.16.13.0/24 is directly connected, Ethernet0/0
D       172.16.0.0/16 is a summary, 00:00:56, Null0
C    192.168.34.0/24 is directly connected, Ethernet0/2

於是,R4 也收到这条 Summary Route。

R4#show ip route | begin Gateway
Gateway of last resort is not set

D    172.16.0.0/16 [90/307200] via 192.168.34.3, 00:01:13, Ethernet0/0
C    192.168.34.0/24 is directly connected, Ethernet0/0

另外,用 Manual 方法发出去的 Summary Route 可以用以下指令更改其构成 Metric 原素的值 (例如 Bandwidth丶Delay 等) 从而更改 Metric,也可以更改其  Administrative Distance。紫色部份依次为 Bandwidth丶Delay丶Reliability丶Loading 和 MTU。而 distance 後面的值当然就是设定 Administrative Distance。

R3(config)#router eigrp 1
R3(config-router)#summary-metric 172.16.0.0 255.255.224.0 100 100 1 1 1 distance 50

Leak-map

做 Summarization 时还可以做一个微调,就是把 Summarize Route 其中一些 Specific Route 发布,来达成某些条件 (通常是 Route Optimization), 请看以下例子。

eigrp

假设 EIGRP 已经设定好,我们利用之前学过的 summary-address 指令从 R1 把 10.0.0.0 / 22 这条 Summary Route 发布到 R2 和 R3。

R1(config)#interface range ethernet 0/0 - 1
R1(config-if-range)#ip summary-address eigrp 1 10.0.0.0 255.255.252.0

於是,R2 和 R3 就会收到从 R1 来的 Summary Route 10.0.0.0 / 22。

R2#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.2)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 10.0.0.0/22, 1 successors, FD is 409600
        via 192.168.12.1 (409600/128256), Ethernet0/0
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.13.0/24, 2 successors, FD is 307200
        via 192.168.12.1 (307200/281600), Ethernet0/0
        via 192.168.23.3 (307200/281600), Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
R3#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.3)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 10.0.0.0/22, 1 successors, FD is 409600
        via 192.168.13.1 (409600/128256), Ethernet0/1
P 192.168.12.0/24, 2 successors, FD is 307200
        via 192.168.13.1 (307200/281600), Ethernet0/1
        via 192.168.23.2 (307200/281600), Ethernet0/0
P 192.168.13.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0

但是现在我们想在 R1 加上一道 Leak-map,让 10.0.1.0 / 24 这条 Route 从 E0/0 发布出去,看看会有什麽改变?

R1(config)#access-list 1 permit 10.0.1.0 0.0.0.255
R1(config)#route-map EIGRP-Leak
R1(config-route-map)#match ip address 1
R1(config-route-map)#exit
R1(config)#interface ethernet 0/0
R1(config-if)#ip summary-address eigrp 1 10.0.0.0 255.255.252.0 leak-map EIGRP-Leak

发现 R2 和 R3 都增加了一条 10.0.1.0 / 24 这条 Route。

R2#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.2)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 10.0.0.0/22, 1 successors, FD is 409600
        via 192.168.12.1 (409600/128256), Ethernet0/0
P 10.0.1.0/24, 1 successors, FD is 409600
        via 192.168.12.1 (409600/128256), Ethernet0/0
P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.13.0/24, 2 successors, FD is 307200
        via 192.168.12.1 (307200/281600), Ethernet0/0
        via 192.168.23.3 (307200/281600), Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
R3#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.3)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 10.0.0.0/22, 1 successors, FD is 409600
        via 192.168.13.1 (409600/128256), Ethernet0/1
P 10.0.1.0/24, 1 successors, FD is 435200
        via 192.168.23.2 (435200/409600), Ethernet0/0
P 192.168.12.0/24, 2 successors, FD is 307200
        via 192.168.13.1 (307200/281600), Ethernet0/1
        via 192.168.23.2 (307200/281600), Ethernet0/0
P 192.168.13.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0

再看看 R3 的 Route Table,设定 Leak-map 的结果是 R3 如果想到 10.0.1.0 / 24 会用 R3→R2→R1 这条 Path,其馀的 10.0.0.0 / 22 才会用 R3→R1。

R3#show ip route | begin Gateway
Gateway of last resort is not set

D    192.168.12.0/24 [90/307200] via 192.168.23.2, 00:26:38, Ethernet0/0
                     [90/307200] via 192.168.13.1, 00:26:38, Ethernet0/1
C    192.168.13.0/24 is directly connected, Ethernet0/1
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D       10.0.0.0/22 [90/409600] via 192.168.13.1, 00:25:16, Ethernet0/1
D       10.0.1.0/24 [90/435200] via 192.168.23.2, 00:03:37, Ethernet0/0
C    192.168.23.0/24 is directly connected, Ethernet0/0

Query and Reply

早前说过,EIGRP 使用了 Feasible Successor 的机制,当发现使用中的 Route 出现问题时,立刻使用 Feasible Successor 顶上。不过,在没有 Feasible Successor 的情况下,EIGRP 也不是把 Route Drop 了就算,它还是会尽力找找有没有其他方法到达目的地,办法就是使用 Query Message,向相邻的 Neighbor 查询有没有到达目的地的方法,当一只 Router 收到 Query Message,如果它有到达目的地的路径,它就会使用 Reply Message 回覆,如果它也不知道的话,它会再向相邻的 Neighbor 发 Query Message,如是者一路问下去,希望网络中有 Router 能够回覆答案。

eigrp

在上图的例子中,假设 R1 有去 172.16.20.0 / 24 的 Route,但这条 Route 突然中断了,由於 R1 并没有到 172.16.20.0 / 24 的 Feasible Successor,因此 R1 向其他 Neighbor 发出 Query。

  1. 172.16.20.0 / 24 突然失效了,R1 想找另外的办法到这个网络。
  2. R1 向 R2 和 R4 发出 Query,查询有没有到 172.16.20.0 / 24 的办法。
  3. R2 和 R4 都无法到达 172.16.20.0 / 24,於是它们又分别向 R3 和 R5 发出 Query。
  4. R3 没有方法到达,由於它已没有其他 Neighbor 可以查询,於是他向 R2 发 Reply,表示没有方法到达,R2 收到後也向 R1 发 Reply ,表示不能到达。
  5. R5 有去 172.16.20.0 / 24 的 Route,因此发 Reply 给 R4 表示他知道怎样去这个网络,R4 收到後也 Reply R1 表示可以到达,最 R1 便更新的 EIGRP Route 把 172.16.20.0 / 24 的路径指向 R4。

当 R1 发出 Query 後,172.16.20.0 / 24 这条 Route 会由 Passive 转到 Active 的状态,意思是正向其他 Neighbor 查询,直到收齐所有 Reply 为止,如果所有 Reply 都表示没有路径到达,EIGRP 就会把这条 Route 移除。但有一个比较特别的情况就是发出 Query 後,因为某些原因是没法集齐 Reply (可能是网络问题),EIGRP 会一直等一直等,直到 Active Timer (预设为 3 分钟) 过了才会停止,判这条 Route 为 Stuck In Active (SIA) 而失效。

正常情况下,EIGRP Topolog Table 中看到的 Route 应该是 Passive (P)。

R2#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.2)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 172.16.20.0/24, 1 successors, FD is 409600
        via 192.168.12.1 (409600/128256), Ethernet0/0
P 172.16.0.0/16, 1 successors, FD is 409600
        via 192.168.12.1 (409600/128256), Ethernet0/0

发出 Query 後会变成 Active (A),并等待回覆。

R2#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.23.2)

Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.12.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0
P 192.168.23.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/1
P 172.16.20.0/24, 1 successors, FD is 409600, U
        via 192.168.12.1 (409600/128256), Ethernet0/0
A 172.16.0.0/16, 1 successors, FD is Inaccessible, Q
    1 replies, active 00:00:25, query-origin: Multiple Origins
      Remaining replies:
         via 192.168.23.3, r, Ethernet0/1

如果收到回覆後会变回 Passive,但如果过了 3 分钟 (Active Timer) 仍没有收到回覆的话,EIGRP 就会判 Stuck in Active 而把 Route 移除。

R2#
*Mar  1 00:27:04.063: %DUAL-3-SIA: Route 172.16.0.0/16 stuck-in-active state in IP-EIGRP(0) 1.  Cleaning up
R2#
*Mar  1 00:27:04.067: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 192.168.23.3 (Ethernet0/1) is down: stuck in active

Stub

Query and Reply 机制产生了一个问题,就是如果 EIGRP 网络非常巨大的话,Router 等待 Reply 的时间就会相对地增加了,因此,我们得想一点办法去控制 Query 的 Boundary,在一些不必要的地方让 Query 不会发生,减少 Query Message 也就能减少 Passive 的时间。但究竟那些才是不应该发生 Query 的地方呢?

eigrp

在这个网络中,R2 和 R3 位於一个 Branch Office,并没有连接到其他网络,即是说,他们在收到 Query 的时候,只会 Reply 「没法到达」,无论问多少次,结果也是一样,向他们 Query 是多馀的。因此,我们可以把 R2 设为 EIGRP Stub,其他 Router 并不会向 Stub 发出 Query。设定方法十分简单:

R2(config)#router eigrp 1
R2(config-router)#eigrp stub

我们也可为 Stub 加入一些附加的功能,例如在 eigrp stub 後加上一个 Keyword receive-only ,意思是让这个 Stub Router 不会发布 Route,只会接收。

R2(config)#router eigrp 1
R2(config-router)#eigrp stub receive-only

除了 receive-only 之外,还有其他的选择:

Keywords 功能
connected 只发布 Connected Route
receive-only 只接收不发布
redistributed 只发布 Redistributed Route
static 只发布 Static Route
summary 只发布 Summary Route

Named Mode

本文从起始以来一直使用的 EIGRP 设定方法称为 Classic Mode,而 EIGRP 还有另一种名为 Named Mode 的设定方法,设定格式有很大改变,请看以下比较。

R1#show run | s eigrp
router eigrp 1
 no auto-summary
 redistibute connected
 network 192.168.12.0
 eigrp stub redistributed
R1#
R1#show run interface ethernet 1/0 | i eigrp
 ip summary-address eigrp 1 192.168.1.0 255.255.255.0

如把以上 Classic Mode 设定转为 Named Mode,格式如下:

R1#show run | s eigrp
router eigrp JANNET
 !
 address-family ipv4 unicast autonomous-system 1
  !
  af-interface Ethernet1/0
   summary-address 192.168.1.0 255.255.255.0
  exit-af-interface
  !
  topology base
   no auto-summary
   redistibute connected
  exit-af-topology
  network 192.168.12.0
  eigrp stub redistributed
 exit-address-family

Classic Mode 好好的,为什麽要搞一个 Named Mode 呢?有以下几个原因。

Multi Address Family

能同时支援多个 Address Family (AF),例如一个 EIGPR Process 能同时处理 IPv4 和 IPv6 的路由交换。

AF Interface Configuration Mode

以前要在 Physical Interface 设定的选项都统一在 Named Mode 里的 AF Interface 中设定,例如:Split-horizon丶Summary Address 等等。

Wide Metric

以往 Metric 公式中,Bandwidth 达到 100Mb 以上的路径并未能在 Metric 中反映出分别,新的公式把份子放大 256 倍,另外加入了 K6,新公式如下:

Metric = [K1 *  BW * 256 + (K2 * BW) / (256-load) + K3 * delay *256 + K6 * Extended Attributes] * [K5 / (reliability + K4)]

where BW = 10^7 Kbit * 256 / interface bandwidth (Kbit)
delay = interface delay (picosecond) * 256 / 1000000

预设 K1=1, K2=0, K3=1, K4=0, K5=0, K6=0,所以公式会被简化成:

Metric = (BW * 256 + delay * 256)
= (BW + delay) * 256

where BW = 10^7 Kbit * 256 / interface bandwidth (Kbit)
delay = interface delay (picosecond) * 256 / 1000000

明显地,Named Mode 的 Metric 值会比 Classic Mode 的大得多,称为 Wide Metric。

Metric Rib-scale

传统 Metric 值长度为 32 Bits,而 Wide Metric 值长度则为 64 Bits。问题出现了,Route Table 所容纳的 Metric 值长度亦是 32 Bits (最大值:4,294,967,296),当 Route 的 Metric 值过大时会出现问题,请看以下例子。

eigrp

图中 R1 使用 Named Mode,而 R2 使用 Classic Mode,R2 把 L0 Redistribute 到 EIGRP。

R1#show run | s eigrp
router eigrp JANNET
 !
 address-family ipv4 unicast autonomous-system 1
  !
  topology base
  exit-af-topology
  network 192.168.12.0
 exit-address-family
R2#show run | s eigrp
router eigrp 1
 network 192.168.12.0
 redistribute connected metric 1 1 1 1 1

可是 R1 的 Route Table 并没有 EIGRP Route。

R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.12.0/24 is directly connected, Ethernet1/0
L        192.168.12.1/32 is directly connected, Ethernet1/0

看看 EIGRP Topology 可见 Route 是收到的,可是 Route 的 Metric 值是 655,426,191,360,远远大於 Route Table 所能容纳的最大值 4,294,967,296,因而无法加进 Route Table。

R1#show ip eigrp topology 
EIGRP-IPv4 VR(JANNET) Topology Table for AS(1)/ID(192.168.12.2)
Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status 

P 192.168.12.0/24, 1 successors, FD is 131072000
        via Connected, Ethernet1/0
P 2.2.2.2/32, 0 successors, FD is Infinity
        via 192.168.12.2 (655426191360/655360655360), Ethernet1/0

有两个方法可以解决此问题,一是调高 Redistribute 时的 Bandwidth 值,Metric 自然减少。另一方法是调整 Metric Rib-scale 基数。

Rib-scale 的原理很简单,Route Metric 值会先除以 Rib-scale 才放进 Route Table。Rib-scale 预设是 128。如果把 Rib-scale 设为 160,那麽 Metric = 655,426,191,360 / 160 = 4,096,413,696,少於 Route Table Metric 最大值,Route 就正常被记在 Route Table 了。

R1(config)#router eigrp JANNET
R1(config-router)#address-family ipv4 autonomous-system 1
R1(config-router-af)#metric rib-scale 160
R1(config-router-af)#end
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, 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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      2.0.0.0/32 is subnetted, 1 subnets
D EX     2.2.2.2 [170/4096413696] via 192.168.12.2, 00:01:48, Ethernet1/0
      192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.12.0/24 is directly connected, Ethernet1/0
L        192.168.12.1/32 is directly connected, Ethernet1/0

相關主題

发表回复

2021-07-22

Posted In: Layer 3 网络技术, menu-tall-2-zh-hans

Leave a Comment