前言
當 Router 能夠透過多於一個 Routing Protocol 到達目的地時,Administrative Distance (AD) 值就充當一個 Priority,讓 Router 選擇使用那一款 Routing Protocol 的路徑。Router 會選擇 AD 值最少的路徑為 Best Path。例如:EIGRP 的 AD 是 90,OSPF 的 AD 是 110,當 Router 發現用 EIGRP 和 OSPF 的路徑都能夠到達目的地,就會選用 AD 值較少的 EIGRP。
預設 Administrative Distance
Cisco Router 預設的 AD 值如下:
Routing Protocol | Administrative Distance (AD) |
---|---|
Directly connected interface | 0 |
Static route out an interface | 1 |
Static route to next-hop address | 1 |
DMNR – Dynamic Mobile Network Routing | 3 |
EIGRP summary route | 5 |
External BGP | 20 |
Internal EIGRP | 90 |
IGRP | 100 |
OSPF | 110 |
IS-IS | 115 |
RIP | 120 |
EGP | 140 |
On Demand Routing (ODR) | 160 |
External EIGRP | 170 |
Internal BGP | 200 |
Floating Static Route | 254 |
Unknown | 255 |
接下來,我們會用以下網絡進行實驗,試試修改 Routing 的 Protocol 的 AD。
各 Router 設定如下:(Routing Protocol 的設定方法並不在本篇文章範圍,如想查看關於 Routing Protocol 的設定,請讀者參考本網關於 Routing Protocol 的文章。)
hostname R1 ! interface Ethernet0/0 ip address 192.168.12.1 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.13.1 255.255.255.0 ! interface Ethernet0/2 ip address 192.168.14.1 255.255.255.0 ! interface Ethernet0/3 ip address 192.168.15.1 255.255.255.0 ! router eigrp 10 network 192.168.12.0 no auto-summary ! router ospf 1 network 192.168.13.0 0.0.0.255 area 0 ! router rip network 192.168.14.0 version 2 no auto-summary ! router bgp 65000 no synchronization neighbor 192.168.15.5 remote-as 65000 no auto-summary
hostname R2 ! interface Ethernet0/0 ip address 192.168.12.2 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.26.2 255.255.255.0 ! router eigrp 10 network 192.168.12.0 network 192.168.26.0 no auto-summary
hostname R3 ! interface Ethernet0/0 ip address 192.168.13.3 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.36.3 255.255.255.0 ! router ospf 1 network 192.168.13.0 0.0.0.255 area 0 network 192.168.36.0 0.0.0.255 area 0
hostname R4 ! interface Ethernet0/0 ip address 192.168.14.4 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.46.4 255.255.255.0 ! router rip network 192.168.14.0 network 192.168.46.0 version 2 no auto-summary
hostname R5 ! interface Ethernet0/0 ip address 192.168.15.5 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.56.5 255.255.255.0 ! router bgp 65000 no synchronization neighbor 192.168.15.1 remote-as 65000 neighbor 192.168.15.1 route-reflector-client neighbor 192.168.56.6 remote-as 65000 no auto-summary
hostname R6 ! interface Loopback0 ip address 192.168.0.1 255.255.255.0 ip ospf network point-to-point ! interface Loopback1 ip address 192.168.1.1 255.255.255.0 ip ospf network point-to-point ! interface Ethernet0/0 ip address 192.168.26.6 255.255.255.0 ! interface Ethernet0/1 ip address 192.168.36.6 255.255.255.0 ! interface Ethernet0/2 ip address 192.168.46.6 255.255.255.0 ! interface Ethernet0/3 ip address 192.168.56.6 255.255.255.0 ! router eigrp 10 network 192.168.0.0 network 192.168.1.0 network 192.168.26.0 no auto-summary ! router ospf 1 network 192.168.0.0 0.0.0.255 area 0 network 192.168.1.0 0.0.0.255 area 0 network 192.168.36.0 0.0.0.255 area 0 ! router rip network 192.168.0.0 network 192.168.1.0 network 192.168.46.0 version 2 no auto-summary ! router bgp 65000 no synchronization network 192.168.0.0 network 192.168.1.0 neighbor 192.168.56.5 remote-as 65000 no auto-summary
查看 R1 的 Route Table,發現正使用 EIGRP 的路徑到達 192.168.0.0/24 和 192.168.1.0/24,因為在 EIGRP、OSPF、RIP 和 iBGP 4 種 Routing Protocol 之中,EIGRP 的 AD 是最少的。
R1#show ip route | include 192.168...0 D 192.168.0.0/24 [90/435200] via 192.168.12.2, 00:02:17, Ethernet0/0 D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:02:17, Ethernet0/0
修改 BGP 的 AD
現在於 R1 嘗試把 iBGP 的 AD 由 200 改為 80,留意 AD 值只用於 Local 而不會外傳,因此網絡裡不同 Router 的 AD 可以不相同。
R1(config)#router bgp 65000 R1(config-router)#distance bgp ? <1-255> Distance for routes external to the AS R1(config-router)#distance bgp 20 ? <1-255> Distance for routes internal to the AS R1(config-router)#distance bgp 20 80 ? <1-255> Distance for local routes R1(config-router)#distance bgp 20 80 200 R1(config-router)#end R1#clear ip bgp * R1# *Mar 1 04:09:33.706: %BGP-5-ADJCHANGE: neighbor 192.168.15.5 Up R1#show ip route | include 192.168...0 B 192.168.0.0/24 [80/0] via 192.168.56.6, 00:00:03 B 192.168.1.0/24 [80/0] via 192.168.56.6, 00:00:03
如果不想全部 BGP Route 的 AD 改變,我們亦可只把其中一條 Route 的 AD 更改,方法是使用 ACL,留意 Source address 是該 Route 的 Advertised Router IP。
R1(config)#router bgp 65000 R1(config-router)#no distance bgp 20 80 200 R1(config-router)#distance 80 ? A.B.C.D IP Source address R1(config-router)#distance 80 192.168.15.5 ? A.B.C.D Wildcard bits R1(config-router)#distance 80 192.168.15.5 0.0.0.0 ? <1-99> IP Standard access list number <1300-1999> IP Standard expanded access list number WORD Standard access-list name <cr> R1(config-router)#distance 80 192.168.15.5 0.0.0.0 1 R1(config-router)#exit R1(config)#access-list 1 permit 192.168.0.0 R1(config)#end R1#clear ip bgp * R1# R1#show ip route | include 192.168...0 B 192.168.0.0/24 [80/0] via 192.168.56.6, 00:00:38 D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:00:40, Ethernet0/0
修改 RIP 的 AD
修改 RIP AD 的方法大同小異:
R1(config)#router rip
R1(config-router)#distance ?
<1-255> Administrative distance
R1(config-router)#distance 70 ?
A.B.C.D IP Source address
<cr>
R1(config-router)#distance 70 192.168.14.4 0.0.0.0 ?
<1-99> IP Standard access list number
<1300-1999> IP Standard expanded access list number
WORD Standard access-list name
<cr>
R1(config-router)#distance 70 192.168.14.4 0.0.0.0 1
R1(config-router)#end
R1#
R1#show ip route | include 192.168...0
R 192.168.0.0/24 [70/1] via 192.168.14.4, 00:00:26, Ethernet0/2
D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:12:00, Ethernet0/0
修改 OSPF 的 AD
至於 OSPF 的 AD 可以按 External, Intra-Area 和 Inter-Area 3 個類型去修改,現在以修改 Intra-Area 為例子:
R1(config)#router ospf 1 R1(config-router)#distance ? <1-255> Administrative distance ospf OSPF distance R1(config-router)#distance ospf ? external External type 5 and type 7 routes inter-area Inter-area routes intra-area Intra-area routes R1(config-router)#distance ospf intra-area 60 R1(config-router)#end R1# R1#show ip route | include 192.168...0 O 192.168.0.0/24 [60/21] via 192.168.13.3, 00:00:05, Ethernet0/1 O 192.168.1.0/24 [60/21] via 192.168.13.3, 00:00:05, Ethernet0/1
當然也可以只選一條 Route 來修改,但流程會較複雜,首先要找出發放 192.168.0.0 這條 Route 的 Advertising Router 的 Router ID:
R1#show ip ospf database router OSPF Router with ID (1.1.1.1) (Process ID 1) Router Link States (Area 0) LS age: 796 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 192.168.1.1 Advertising Router: 192.168.1.1 LS Seq Number: 80000007 Checksum: 0x69C9 Length: 60 Number of Links: 3 Link connected to: a Stub Network (Link ID) Network/subnet number: 192.168.1.0 (Link Data) Network Mask: 255.255.255.0 Number of TOS metrics: 0 TOS 0 Metrics: 1 Link connected to: a Stub Network (Link ID) Network/subnet number: 192.168.0.0 (Link Data) Network Mask: 255.255.255.0 Number of TOS metrics: 0 TOS 0 Metrics: 1 <--Output Omitted-->
R1(config)#router ospf 1
R1(config-router)#distance 60 192.168.1.1 0.0.0.0 1
R1(config-router)#end
R1#
R1#show ip route | include 192.168...0
O 192.168.0.0/24 [60/21] via 192.168.13.3, 00:00:06, Ethernet0/1
D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:09:54, Ethernet0/0
修改 EIGRP 的 AD
最後嘗試修改 EIGRP 的 AD:
R1(config)#router eigrp 10 R1(config-router)#distance ? <1-255> Administrative distance eigrp IP-EIGRP distance R1(config-router)#distance eigrp ? <1-255> Distance for internal routes R1(config-router)#distance eigrp 50 ? <1-255> Distance for external routes R1(config-router)#distance eigrp 50 170 R1(config-router)#end R1# R1#show ip route | include 192.168...0 O 192.168.0.0/24 [60/21] via 192.168.13.3, 00:02:33, Ethernet0/1 D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:12:21, Ethernet0/0 R1# R1#show ip route | include 192.168...0 D 192.168.0.0/24 [50/435200] via 192.168.12.2, 00:00:03, Ethernet0/0 D 192.168.1.0/24 [50/435200] via 192.168.12.2, 00:00:03, Ethernet0/0
亦可按個別 Route 修改:
R1(config)#router eigrp 10
R1(config-router)#no distance eigrp 50 170
R1(config-router)#distance 50 192.168.12.2 0.0.0.0 1
R1(config-router)#end
R1#
R1#show ip route | include 192.168...0
D 192.168.0.0/24 [50/435200] via 192.168.12.2, 00:00:02, Ethernet0/0
D 192.168.1.0/24 [90/435200] via 192.168.12.2, 00:00:02, Ethernet0/0
相關主題
Jan Ho 2014-09-20
Posted In: Layer 3 網絡技術
發佈留言