HuaWei ❀ 对接收和发布的路由进行过滤

对接收和发布的路由进行过滤

如下图所示,网络内R1、R2、R3运行OSPF协议,R4有四个网段路由,要求OSPF只能访问10.1.1.0/24、10.1.2.0/24、10.1.3.0/24三个网段,R1只能访问10.1.1.0/24网段;
在这里插入图片描述

配置接口IP地址:

[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24 

配置OSPF协议:

[r1]ospf 100 router-id 1.1.1.1
[r1-ospf-100]area 0
[r1-ospf-100-area-0.0.0.0]network 13.1.1.0 0.0.0.255

[r2]ospf 100 router-id 2.2.2.2
[r2-ospf-100]area 0
[r2-ospf-100-area-0.0.0.0]network 23.1.1.0 0.0.0.255

[r3]ospf 100 router-id 3.3.3.3
[r3-ospf-100]area 0
[r3-ospf-100-area-0.0.0.0]network 13.1.1.0 0.0.0.255
[r3-ospf-100-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[r3-ospf-100-area-0.0.0.0]network 34.1.1.0 0.0.0.255

[r4]ospf 100 router-id 4.4.4.4
[r4-ospf-100]area 0
[r4-ospf-100-area-0.0.0.0]network 34.1.1.0 0.0.0.255

配置静态路由并引入OSPF协议中:

[r4]ip route-static 10.1.1.1 24 NULL 0
[r4]ip route-static 10.1.2.1 24 NULL 0
[r4]ip route-static 10.1.3.1 24 NULL 0
[r4]ip route-static 10.1.4.1 24 NULL 0

[r4]ospf 100
[r4-ospf-100]import-route static

查看原始路由信息:

[r1]display ip routing-table protocol ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 6        Routes : 6        

OSPF routing table status : <Active>
         Destinations : 6        Routes : 6

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  O_ASE   150  1           D   13.1.1.2        GigabitEthernet0/0/0
       10.1.2.0/24  O_ASE   150  1           D   13.1.1.2        GigabitEthernet0/0/0
       10.1.3.0/24  O_ASE   150  1           D   13.1.1.2        GigabitEthernet0/0/0
       10.1.4.0/24  O_ASE   150  1           D   13.1.1.2        GigabitEthernet0/0/0
       23.1.1.0/24  OSPF    10   2           D   13.1.1.2        GigabitEthernet0/0/0
       34.1.1.0/24  OSPF    10   2           D   13.1.1.2        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

配置前缀列表:

[r4]ip ip-prefix aaa index 5 permit 10.1.1.1 24
[r4]ip ip-prefix aaa index 10 permit 10.1.2.1 24
[r4]ip ip-prefix aaa index 15 permit 10.1.3.1 24

[r4]ospf 100
[r4-ospf-100]filter-policy ip-prefix aaa export static

[r1]ip ip-prefix aaa index 5 permit 10.1.1.1 24

[r1]ospf 100
[r1-ospf-100]filter-policy ip-prefix aaa import

查看R3配置后的路由信息:

[r3]display ip routing-table protocol ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 3        Routes : 3        

OSPF routing table status : <Active>
         Destinations : 3        Routes : 3

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  O_ASE   150  1           D   34.1.1.2        GigabitEthernet0/0/2
       10.1.2.0/24  O_ASE   150  1           D   34.1.1.2        GigabitEthernet0/0/2
       10.1.3.0/24  O_ASE   150  1           D   34.1.1.2        GigabitEthernet0/0/2

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

查看R1配置后的路由信息:

[r1]display ip routing-table protocol ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 1        Routes : 1        

OSPF routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  O_ASE   150  1           D   13.1.1.2        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

猜你喜欢

转载自blog.csdn.net/qq_42197548/article/details/105867893