HCIP学习(2)-- 路由引入

一. 路由引入的基本概念

  路由引入指的是将路由信息从一种路由协议发布到另一种路由协议的操作。

    通过路由引入,可以实现路由信息在不同路由协议间传递;

    执行路由引入时,还可以部署路由控制,从而实现对业务流量的灵活把控。

二. 实例讲解

设备编号 端口 IP配置
AR2220-AR1 GE0/0/0 1.1.1.1/24
AR2220-AR2 GE0/0/0 1.1.1.2/24
GE0/0/1 192.168.2.254/24
AR2220-AR3 GE0/0/0 192.168.2.100/24
GE0/0/1 192.168.3.254/24
PC-PC1 /

192.168.3.1/24

GateWay:192.168.3.254

 配置思路:

1.在AR1路由器使能OSPF协议,使用OSPF协议学习路由。

2.AR2作为ASBR,处于两个不同协议的区域边界处,一边是OSPF协议,另一边是RIP协议。

3.在AR3路由器使能RIP协议,使用RIP协议学习路由。

基础配置:

AR01:
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]interface  GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 1.1.1.1 24
Aug 17 2023 15:20:54-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ospf 1   #使能OSPF协议
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net    
[Huawei-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
AR3:
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.2.100 24
Aug 17 2023 15:27:43-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]q
[Huawei]rip 1    #使能RIP协议
[Huawei-rip-1]version 2
[Huawei-rip-1]network 192.168.2.0
[Huawei-rip-1]q
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.3.254 24
Aug 17 2023 15:30:16-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol
 IP on the interface GigabitEthernet0/0/1 has entered the UP state. 
[Huawei-GigabitEthernet0/0/1]q
[Huawei]rip 1
[Huawei-rip-1]net    
[Huawei-rip-1]network 192.168.3.0
[Huawei-rip-1]q
AR2:
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 1.1.1.2 24
Aug 17 2023 15:23:16-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[Huawei-GigabitEthernet0/0/0]q      
[Huawei]ospf 1
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.2.254 24
[Huawei-GigabitEthernet0/0/1]q  
[Huawei]rip 1
[Huawei-rip-1]version 2
[Huawei-rip-1]network 192.168.2.0
[Huawei-rip-1]q

实施以上实例的目的,是实现AR1能够ping通PC1。现在来尝试一下:

<Huawei>ping 192.168.3.1
  PING 192.168.3.1: 56  data bytes, press CTRL_C to break
    Request time out
    Request time out
    Request time out
    Request time out
    Request time out

  --- 192.168.3.1 ping statistics ---
    5 packet(s) transmitted
    0 packet(s) received
    100.00% packet loss

通过以上,可以看出AR1不能ping通PC1,由于两者不属于同一网段,查看AR1的路由发现没有到192.168.3.0网段的路由条目,因为AR1和AR3使用的路由协议不同,所以无法自动学习,这是需要配置路由引入,此处的配置必须在ASBR路由器上配置,即AR2。

AR2:
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]display ip routing-table 192.168.3.1 #在ASBR(AR2)上存在到192.168.3.0网段的路由 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.3.0/24 RIP 100 1 D 192.168.2.100 GigabitEthernet 0/0/1 [Huawei]ospf 1 [Huawei-ospf-1]import-route ? #路由引入 bgp Border Gateway Protocol (BGP) routes direct Connected routes isis Intermediate System to Intermediate System (IS-IS) routes limit Limit the number of routes imported into OSPF ospf Open Shortest Path First (OSPF) routes rip Routing Information Protocol (RIP) routes static Static routes unr User Network Routes [Huawei-ospf-1]import-route rip ? #路由引入的协议类型 INTEGER<1-65535> Process ID cost Set cost route-policy Route policy tag Specify route tag type Metric type of the imported external routes <cr> Please press ENTER to execute command [Huawei-ospf-1]import-route rip 1 ? #路由引入协议的cost,可以自行设置 cost Set cost route-policy Route policy tag Specify route tag type Metric type of the imported external routes <cr> Please press ENTER to execute command [Huawei-ospf-1]import-route rip 1 cost 123 #为了实现网段1.1.1.0能够通过路由器学习到192.168.3.0网段的路由,在此路由器实现路由引入,将RIP路由转换为OSPF路由 [Huawei-ospf-1]q

配置完成后,查看AR1的路由表:

AR1:
<Huawei>display ip routing-table 192.168.3.1 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.3.0/24 O_ASE 150 123 D 1.1.1.2 GigabitEthernet 0/0/0

现在在AR1路由器上已经学习到192.168.3.0网段的路由路径,此时重新ping PC1:

AR1:
<Huawei>ping 192.168.3.1 PING 192.168.3.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 192.168.3.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss

发现仍然ping不通,因为网络中的通信是双向的,虽然在AR1中已存在到192.168.3.0网段的路由,但是AR3上没有到1.1.1.0网段的路由,还需要在ASBR(AR2)上配置路由引入,实现通信。

AR2:
[Huawei]rip 1 [Huawei-rip-1]import-route ospf 1 ? cost Cost of the import route route-policy Apply the specified route policy to filter route <cr> Please press ENTER to execute command [Huawei-rip-1]import-route ospf 1 cost 3 #路由引入,运行RIP路由学习到OSPF协议路由 [Huawei-rip-1]q

配置完成后,查看AR3的路由表:

AR3:
<Huawei>display ip routing-table 1.1.1.1 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Table : Public Summary Count : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.0/24 RIP 100 4 D 192.168.2.254 GigabitEthernet 0/0/0

现在在AR3路由器上已经学习到1.1.1.0网段的路由路径,此时重新ping:

AR1:
<Huawei>ping 192.168.3.1 PING 192.168.3.1: 56 data bytes, press CTRL_C to break Request time out Reply from 192.168.3.1: bytes=56 Sequence=2 ttl=126 time=40 ms Reply from 192.168.3.1: bytes=56 Sequence=3 ttl=126 time=30 ms Reply from 192.168.3.1: bytes=56 Sequence=4 ttl=126 time=20 ms Reply from 192.168.3.1: bytes=56 Sequence=5 ttl=126 time=50 ms --- 192.168.3.1 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 20/35/50 ms

此时,实现互相通信。

(在配置路由引入时,可以实现对路由的控制,流量管理,通过配置路由策略(根据协议的优先级)来实现。)

三. 路由引入理论

  1.路由引入的方向性

  路由引入是具有方向性的,将路由信息从路由协议A引入到路由协议B(A-to-B),则路由协议B可获知A中的路由信息,但是此时,A还并不知晓B路由协议中的路由信息,除非配置B-to-A的路由引入。

路由引入需要注意的几点:

(1)路由优先级

 次优路径的出现是由于路由协议的优先级大小导致的。从上图中可知:

修改路由协议的优先级:

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.    
[Huawei]ospf 1
[Huawei-ospf-1]preference ?
  INTEGER<1-255>  Preference value
  ase             AS external link states
  route-policy    Route policy    
[Huawei-ospf-1]preference ase 14    #修改优先级

R3到R4的路由协议是IS-IS,其优先级为15;R1到R3的优先级是O_ASE,默认优先级为150。通过比较优先级,R3与R1实现通信会选择R3-R4-R2-R1,但实际上这样的通信会产生延迟,不是最优路径。若想要解决此类问题,需要在进行路由引入时注意路由协议的优先级。在此调整R3-R1的路由优先级小于15,即可解决。(路由优先级数值越小,越优)

(2)路由回灌 

 路由回灌,即路由循环,尽量避免,可能会造成环路。

(3)路由度量值

  2. 路由引入场景

  路由引入主要涉及以下几种场景:

    (1)动态路由协议之间的路由引入

    (2)引入直连路由到动态路由协议

    (3)引入静态路由到动态路由协议

 

热门相关:亿万盛宠只为你   后福   拒嫁豪门,前妻太抢手   买妻种田:山野夫君,强势宠!   今天也没变成玩偶呢