使用Route-policy控制路由

使用Route-policy控制路由

拓撲圖

在這裏插入圖片描述

實驗過程

IP地址選配

設備名稱 接口 ip地址 網關
PCA 10.0.1.2/24 10.0.1.1
PCB 10.0.2.2/24 10.0.2.1
RTA G0/0 10.0.1.1/24
S5/0 192.168.1.1/30
S5/1 192.168.1.5/30
RTB S5/0 192.168.1.2/30
S5/1 192.168.2.1/30
RTC S5/0 192.168.1.6/30
S5/1 192.168.2.5/30
RTD G0/0 10.0.2.1/24
S5/0 192.168.2.2/30
S5/1 192.168.2.6/30

在pc及路由上配置ip地址。

設置PC IP

PCA
在這裏插入圖片描述
PCB
在這裏插入圖片描述

基本配置

RTA

<H3C>sys
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]hostname RTA
[RTA]int g0/0
[RTA-GigabitEthernet0/0]ip add 10.0.1.1 24
[RTA-GigabitEthernet0/0]no shu
[RTA-GigabitEthernet0/0]no shutdown
[RTA-GigabitEthernet0/0]exit
[RTA]int g5/0
[RTA-GigabitEthernet5/0]ip add 192.168.1.1 30
[RTA-GigabitEthernet5/0]no shutdown
[RTA-GigabitEthernet5/0]exit
[RTA]int g5/1
[RTA-GigabitEthernet5/1]ip add 192.168.1.5 30
[RTA-GigabitEthernet5/1]no shutdown
[RTA-GigabitEthernet5/1]exit
[RTA]

RTB

<H3C>SYS
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]hostname RTB
[RTB]int g5/0
[RTB-GigabitEthernet5/0]ip add 192.168.1.2 30
[RTB-GigabitEthernet5/0]no shu
[RTB-GigabitEthernet5/0]no shutdown
[RTB-GigabitEthernet5/0]exi
[RTB-GigabitEthernet5/0]exit
[RTB]int g5/1
[RTB-GigabitEthernet5/1]ip add 192.168.2.1 30
[RTB-GigabitEthernet5/1]no shu
[RTB-GigabitEthernet5/1]no shutdown
[RTB-GigabitEthernet5/1]exi
[RTB-GigabitEthernet5/1]exit
[RTB]

RTC

[H3C]hostname RTC
[RTC]int g5/0
[RTC-GigabitEthernet5/0]ip add 192.168.1.6 30
[RTC-GigabitEthernet5/0]no shu
[RTC-GigabitEthernet5/0]no shutdown
[RTC-GigabitEthernet5/0]exi
[RTC-GigabitEthernet5/0]exit
[RTC]int g5/1
[RTC-GigabitEthernet5/1]ip add 192.168.2.5 30
[RTC-GigabitEthernet5/1]no shu
[RTC-GigabitEthernet5/1]no shutdown
[RTC-GigabitEthernet5/1]exi
[RTC-GigabitEthernet5/1]exit
[RTC]

RTD

[H3C]hostname RTD
[RTD]int g0/0
[RTD-GigabitEthernet0/0]ip add 10.0.2.1 24
[RTD-GigabitEthernet0/0]no shu
[RTD-GigabitEthernet0/0]no shutdown
[RTD-GigabitEthernet0/0]exi
[RTD-GigabitEthernet0/0]exit
[RTD]int g5/0
[RTD-GigabitEthernet5/0]ip add 192.168.2.2 30
[RTD-GigabitEthernet5/0]no shu
[RTD-GigabitEthernet5/0]no shutdown
[RTD-GigabitEthernet5/0]exi
[RTD-GigabitEthernet5/0]exit
[RTD]int g5/1
[RTD-GigabitEthernet5/1]ip add 192.168.2.6 30
[RTD-GigabitEthernet5/1]no shu
[RTD-GigabitEthernet5/1]no shutdown
[RTD-GigabitEthernet5/1]exi
[RTD-GigabitEthernet5/1]exit
[RTD]

引入靜態路由

在路由器RTA、RTB、RTC上啓用RIPV2進行路由學習,並將RTB和RTC的接口s5/0的路由發佈,再RTA上配置靜態路由10.1.0.0/24 和10.1.1.0/24,並將靜態路由引入到rip協議中,並將所引入的路由缺省度量值改爲2

配置RTA

[RTA]ip route-static 10.1.0.0 24 10.0.1.2
[RTA]ip route-static 10.1.1.0 24 10.0.1.2
[RTA]rip
[RTA-rip-1]network 10.0.0.0
[RTA-rip-1]network 192.168.1.0
[RTA-rip-1]version 2
[RTA-rip-1]undo summary
[RTA-rip-1]import-route static
[RTA-rip-1]default cost 2
[RTA-rip-1]

配置RTB

[RTB]rip
[RTB-rip-1]ne
[RTB-rip-1]network 192.168.1.0
[RTB-rip-1]ve
[RTB-rip-1]version 2
[RTB-rip-1]un
[RTB-rip-1]undo sum
[RTB-rip-1]undo summary
[RTB-rip-1]

配置RTC


[RTC]rip
[RTC-rip-1]network 192.168.1.0
[RTC-rip-1]version 2
[RTC-rip-1]undo summary
[RTC-rip-1]

配置完成之後在RTB和RTC上查看路由表,如下所示:

[RTB]dis ip routing-table

Destinations : 20       Routes : 20

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        RIP     100 1           192.168.1.1     GE5/0
10.1.0.0/24        RIP     100 3           192.168.1.1     GE5/0
10.1.1.0/24        RIP     100 3           192.168.1.1     GE5/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.2     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.4/30     RIP     100 1           192.168.1.1     GE5/0
192.168.2.0/30     Direct  0   0           192.168.2.1     GE5/1
192.168.2.0/32     Direct  0   0           192.168.2.1     GE5/1
192.168.2.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.1     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTB]

[RTC]dis ip routing-table

Destinations : 20       Routes : 20

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        RIP     100 1           192.168.1.5     GE5/0
10.1.0.0/24        RIP     100 3           192.168.1.5     GE5/0
10.1.1.0/24        RIP     100 3           192.168.1.5     GE5/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     RIP     100 1           192.168.1.5     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.6     GE5/0
192.168.1.4/32     Direct  0   0           192.168.1.6     GE5/0
192.168.1.6/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.6     GE5/0
192.168.2.4/30     Direct  0   0           192.168.2.5     GE5/1
192.168.2.4/32     Direct  0   0           192.168.2.5     GE5/1
192.168.2.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.7/32     Direct  0   0           192.168.2.5     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTC]

在這裏插入圖片描述
在這裏插入圖片描述
可見RTA將引入的路由10.1.0.0/24和10.1.1.0/24發佈給RTB和RTC,度量值爲3(缺省度量值再加1)

引入的路由過濾

配置引入路由後,所有的靜態路由都獎引入到RIP路由表中,爲了有選擇性的引入所需要的路由,可以在RTA上配置ROUTE-POLICY,將引入路由10.1.0.0/24.

配置RTA

[RTA]ip prefix-list  abc index 10 permit 10.1.0.0 24
[RTA]route-policy abc permit node 10
[RTA-route-policy-abc-10]if-match ip address prefix-list abc
[RTA-route-policy-abc-10]quit
[RTA]rip
[RTA-rip-1]import-route static route-policy abc

配置完成後,查看RTB和RTC的路由表,如下表示:

[RTB]dis ip routing-table

Destinations : 19       Routes : 19

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        RIP     100 1           192.168.1.1     GE5/0
10.1.0.0/24        RIP     100 3           192.168.1.1     GE5/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.2     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.4/30     RIP     100 1           192.168.1.1     GE5/0
192.168.2.0/30     Direct  0   0           192.168.2.1     GE5/1
192.168.2.0/32     Direct  0   0           192.168.2.1     GE5/1
192.168.2.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.1     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTB]

在這裏插入圖片描述

[RTC]dis ip routing-table

Destinations : 19       Routes : 19

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        RIP     100 1           192.168.1.5     GE5/0
10.1.0.0/24        RIP     100 3           192.168.1.5     GE5/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     RIP     100 1           192.168.1.5     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.6     GE5/0
192.168.1.4/32     Direct  0   0           192.168.1.6     GE5/0
192.168.1.6/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.6     GE5/0
192.168.2.4/30     Direct  0   0           192.168.2.5     GE5/1
192.168.2.4/32     Direct  0   0           192.168.2.5     GE5/1
192.168.2.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.7/32     Direct  0   0           192.168.2.5     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTC]

在這裏插入圖片描述
可以看到RTB、RTC路由表沒有了RTA上的10.1.1.0/24路由,因爲RTA在引入時,可以把它過濾掉了。

OSPF路由配置

在RTB、RTC和RTD上配置OSPF單區域,規劃區域爲0,並將RTB和RTC的接口在S5/1的路由發佈

配置RTB


[RTB]ospf
[RTB-ospf-1]ar
[RTB-ospf-1]area 0
[RTB-ospf-1-area-0.0.0.0]ne
[RTB-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.3
[RTB-ospf-1-area-0.0.0.0]

配置RTC

[RTC]OSPF
[RTC-ospf-1]area 0
[RTC-ospf-1-area-0.0.0.0]network 192.168.2.4 0.0.0.3
[RTC-ospf-1-area-0.0.0.0]

配置RTD

[RTD]ospf
[RTD-ospf-1]a
[RTD-ospf-1]area 0
[RTD-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255
[RTD-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.3
[RTD-ospf-1-area-0.0.0.0]network 192.168.2.4 0.0.0.3

配置完成之後,查看RTA和RTD的路由表,如下所示:

[RTA]dis ip routing-table

Destinations : 22       Routes : 22

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        Direct  0   0           10.0.1.1        GE0/0
10.0.1.0/32        Direct  0   0           10.0.1.1        GE0/0
10.0.1.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.1.255/32      Direct  0   0           10.0.1.1        GE0/0
10.1.0.0/24        Static  60  0           10.0.1.2        GE0/0
10.1.1.0/24        Static  60  0           10.0.1.2        GE0/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.1     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.5     GE5/1
192.168.1.4/32     Direct  0   0           192.168.1.5     GE5/1
192.168.1.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.5     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTA]

[RTD]dis ip routing-table

Destinations : 20       Routes : 20

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.2.0/24        Direct  0   0           10.0.2.1        GE0/0
10.0.2.0/32        Direct  0   0           10.0.2.1        GE0/0
10.0.2.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.2.255/32      Direct  0   0           10.0.2.1        GE0/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.2.0/30     Direct  0   0           192.168.2.2     GE5/0
192.168.2.0/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.4/30     Direct  0   0           192.168.2.6     GE5/1
192.168.2.4/32     Direct  0   0           192.168.2.6     GE5/1
192.168.2.6/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.7/32     Direct  0   0           192.168.2.6     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTD]

RTA上沒有路由10.0.2.0/24,RTD上沒有路由10.0.1.0/24和10.1.0.0/24.

配置雙邊界引入

在RTB和RTC 上配置雙邊界引入,分別將ospf和rip的路由引入對方,其中,配置rtb將opsf路由引入到rip中,配置rtc將rip引入到ospf中。

配置RTB


[RTB]rip
[RTB-rip-1]import-route ospf
[RTB-rip-1]

配置RTC

[RTc]ospf
[RTC-ospf-1]import-route rip

配置完成後,再查看RTA和RTD的路由表,如下表示:

[RTA]dis ip routing-table

Destinations : 24       Routes : 24

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        Direct  0   0           10.0.1.1        GE0/0
10.0.1.0/32        Direct  0   0           10.0.1.1        GE0/0
10.0.1.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.1.255/32      Direct  0   0           10.0.1.1        GE0/0
10.0.2.0/24        RIP     100 1           192.168.1.2     GE5/0
10.1.0.0/24        Static  60  0           10.0.1.2        GE0/0
10.1.1.0/24        Static  60  0           10.0.1.2        GE0/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.1     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.5     GE5/1
192.168.1.4/32     Direct  0   0           192.168.1.5     GE5/1
192.168.1.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.5     GE5/1
192.168.2.4/30     RIP     100 1           192.168.1.2     GE5/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTA]

[RTD]dis ip routing-table

Destinations : 23       Routes : 23

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        O_ASE2  150 1           192.168.2.5     GE5/1
10.0.2.0/24        Direct  0   0           10.0.2.1        GE0/0
10.0.2.0/32        Direct  0   0           10.0.2.1        GE0/0
10.0.2.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.2.255/32      Direct  0   0           10.0.2.1        GE0/0
10.1.0.0/24        O_ASE2  150 1           192.168.2.5     GE5/1
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     O_ASE2  150 1           192.168.2.5     GE5/1
192.168.2.0/30     Direct  0   0           192.168.2.2     GE5/0
192.168.2.0/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.4/30     Direct  0   0           192.168.2.6     GE5/1
192.168.2.4/32     Direct  0   0           192.168.2.6     GE5/1
192.168.2.6/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.7/32     Direct  0   0           192.168.2.6     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTD]

RTA上學到了路由10.0.2.0/24,RTD上也學到了路由10.0.1.0/24和10.1.0.0/24.

路由環路產生

配置路由邊界中後,在某些情況下可能會導致路由環路或者錯誤。下面我們人爲地製造這個環路。在RTA上將靜態路由由10.1.0.0/24的優先級改爲120.

配置RTC

[RTA]ip route-static 10.1.0.0 24 10.0.1.2 preference 120

然後在RTB上將rip協議的優先級改爲200,以使RTB能夠將從RTD學到10.1.0.0/24路由向rip域內發佈。

配置RTB

[RTB]rip
[RTB-rip-1]preference 200
[RTA]dis ip routing-table

Destinations : 25       Routes : 26

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        Direct  0   0           10.0.1.1        GE0/0
10.0.1.0/32        Direct  0   0           10.0.1.1        GE0/0
10.0.1.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.1.255/32      Direct  0   0           10.0.1.1        GE0/0
10.0.2.0/24        RIP     100 1           192.168.1.2     GE5/0
                                           192.168.1.6     GE5/1
10.1.0.0/24        RIP     100 1           192.168.1.2     GE5/0
10.1.1.0/24        Static  60  0           10.0.1.2        GE0/0
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.1     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.5     GE5/1
192.168.1.4/32     Direct  0   0           192.168.1.5     GE5/1
192.168.1.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.5     GE5/1
192.168.2.0/30     RIP     100 1           192.168.1.6     GE5/1
192.168.2.4/30     RIP     100 1           192.168.1.2     GE5/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTA]

[RTB]dis ip routing-table

Destinations : 21       Routes : 21

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        O_ASE2  150 1           192.168.2.2     GE5/1
10.0.2.0/24        O_INTRA 10  2           192.168.2.2     GE5/1
10.1.0.0/24        O_ASE2  150 1           192.168.2.2     GE5/1
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.2     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.2     GE5/0
192.168.1.4/30     RIP     200 1           192.168.1.1     GE5/0
192.168.2.0/30     Direct  0   0           192.168.2.1     GE5/1
192.168.2.0/32     Direct  0   0           192.168.2.1     GE5/1
192.168.2.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.1     GE5/1
192.168.2.4/30     O_INTRA 10  2           192.168.2.2     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTB]

可見,錯誤出現了,RTA以爲通過了RTB能到10.1.0.0/24,而RTB以爲通過RTD能到10.1.0.0/24,RTD以爲能通過RTC到10.1.0.0/24,RTC又以爲通過RTA能到10.1.0.0/24。
路由環路發生了。在RTA在查到到達 10.1.0.0/24 的路徑,如下所示:

<RTA>tra
<RTA>tracert 10.1.0.1
traceroute to 10.1.0.1 (10.1.0.1), 30 hops at most, 40 bytes each packet, press CTRL_C to                                                                                                                                                   break
 1  * * *
 2  * * *
 3  * * *
 4  * *

[RTD]dis ip routing-table

Destinations : 23       Routes : 23

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        O_ASE2  150 1           192.168.2.5     GE5/1
10.0.2.0/24        Direct  0   0           10.0.2.1        GE0/0
10.0.2.0/32        Direct  0   0           10.0.2.1        GE0/0
10.0.2.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.2.255/32      Direct  0   0           10.0.2.1        GE0/0
10.1.0.0/24        O_ASE2  150 1           192.168.2.5     GE5/1
127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     O_ASE2  150 1           192.168.2.5     GE5/1
192.168.2.0/30     Direct  0   0           192.168.2.2     GE5/0
192.168.2.0/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.2/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.3/32     Direct  0   0           192.168.2.2     GE5/0
192.168.2.4/30     Direct  0   0           192.168.2.6     GE5/1
192.168.2.4/32     Direct  0   0           192.168.2.6     GE5/1
192.168.2.6/32     Direct  0   0           127.0.0.1       InLoop0
192.168.2.7/32     Direct  0   0           192.168.2.6     GE5/1
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
[RTD]

使用TAG選擇性引入路由


[RTA]rip
[RTA-rip-1]import-route ospf tag 10
[RTA-rip-1]quit
[RTB]route-policy abc deny node 10
[RTB-route-policy-abc-10]if-match tag 10
[RTB-route-policy-abc-10]qui
[RTB-route-policy-abc-10]quit
[RTB]route-policy abc permit node 20
[RTB-route-policy-abc-20]quit
[RTB]rip
[RTB-rip-1]import-route ospf route-policy abc
[RTB-rip-1]

<RTA>dis ip routing-table

Destinations : 25       Routes : 26

Destination/Mask   Proto   Pre Cost        NextHop         Interface
0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0
10.0.1.0/24        Direct  0   0           10.0.1.1        GE0/0
10.0.1.0/32        Direct  0   0           10.0.1.1        GE0/0
10.0.1.1/32        Direct  0   0           127.0.0.1       InLoop0
10.0.1.255/32      Direct  0   0           10.0.1.1        GE0/0
10.0.2.0/24        RIP     100 1           192.168.1.2     GE5/0
                                           192.168.1.6     GE5/1
10.1.0.0/24        RIP     100 1           192.168.1.2     GE5/0

10.1.1.0/24        Static  120  0           10.0.1.2        GE0/0

127.0.0.0/8        Direct  0   0           127.0.0.1       InLoop0
127.0.0.0/32       Direct  0   0           127.0.0.1       InLoop0
127.0.0.1/32       Direct  0   0           127.0.0.1       InLoop0
127.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
192.168.1.0/30     Direct  0   0           192.168.1.1     GE5/0
192.168.1.0/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.1/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.3/32     Direct  0   0           192.168.1.1     GE5/0
192.168.1.4/30     Direct  0   0           192.168.1.5     GE5/1
192.168.1.4/32     Direct  0   0           192.168.1.5     GE5/1
192.168.1.5/32     Direct  0   0           127.0.0.1       InLoop0
192.168.1.7/32     Direct  0   0           192.168.1.5     GE5/1
192.168.2.0/30     RIP     100 1           192.168.1.6     GE5/1
192.168.2.4/30     RIP     100 1           192.168.1.2     GE5/0
224.0.0.0/4        Direct  0   0           0.0.0.0         NULL0
224.0.0.0/24       Direct  0   0           0.0.0.0         NULL0
255.255.255.255/32 Direct  0   0           127.0.0.1       InLoop0
<RTA>

可以看到,路由10.1.0.0/24被過濾,所以RTA上僅有靜態路由了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章