Plusieurs types de filtre en OSPF
- distribute-list x in
- area x filter-list prefix x in
- area x filter-list prefix x out
- distribute-list x out
- area x.x.x.x x.x.x.x not-advertise
- summary-address x.x.x.x x.x.x.x not-advertise
distribute-list x in :
Permet de filtrer les routes OSPF (tout type) qui seront injectés (ou pas) dans la table routage locale du routeur
"distribute-list x in" n'a aucun impact sur la réception et l'annonce OSPF
Exemple:
R3#show ip route 1.1.1.0
Routing entry for 1.1.1.0/24
Known via "ospf 1", distance 110, metric 782, type intra area
Last update from 10.1.13.1 on Serial1/2, 00:00:04 ago
Routing Descriptor Blocks:
* 10.1.13.1, from 1.1.1.1, 00:00:04 ago, via Serial1/2
Route metric is 782, traffic share count is 1
Filtre le sous réseau 1.1.1.0 /24 :
R3#conf t
R3(config)#access-list 1 deny 1.1.1.0 0.0.0.255
R3(config)#access-list 1 permit any
R3(config)#router ospf 1
R3(config-router)#distribute-list 1 in
Vérification :
R3#show ip route 1.1.1.0
% Network not in table
"distribute-list" peut être utilisé avec route-map et ainsi filtrer les types de routes (E1, E2), les tag ... ou autres
route-map DROP-E2 deny 10
match route-type external type-2
!
route-map DROP-E2 permit 20
!
route-map DROP-TAG-111 deny 10
match tag 111
!
route-map DROP-TAG-111 permit 20
!
router ospf 1
log-adjacency-changes
network 10.1.1.4 0.0.0.0 area 0
network 10.11.11.1 0.0.0.0 area 0
distribute-list route-map DROP-E2 in
area x filter-list prefix x in :
"area x filter-list prefix x in" permet de filtrer les LSA de type 3 sur un ABR
le sous réseau 11.1.1.0/24 est présent dans l'area 0 et est diffusé dans l'area 2 par l'ABR R4 (schéma plus haut)
Le sous réseau 11.1.1.0/24 est donc présent dans R5 :
R5#show ip route 11.1.1.1
Routing entry for 11.1.1.0/24
Known via "ospf 1", distance 110, metric 896, type inter area
Last update from 10.1.45.4 on Serial0/0.54, 00:05:36 ago
Routing Descriptor Blocks:
* 10.1.45.4, from 4.4.4.4, 00:05:36 ago, via Serial0/0.54
Route metric is 896, traffic share count is 1
11.1.1.0/24 est présent dans la database OSPF de l'ABR R4 :
R4#show ip ospf database summary 11.1.1.0
OSPF Router with ID (4.4.4.4) (Process ID 1)
Summary Net Link States (Area 0)
Routing Bit Set on this LSA
LS age: 758
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 11.1.1.0 (summary Network Number)
Advertising Router: 3.3.3.3
LS Seq Number: 80000001
Checksum: 0x30E2
Length: 28
Network Mask: /24
TOS: 0 Metric: 782
Summary Net Link States (Area 2)
LS age: 14
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 11.1.1.0 (summary Network Number)
Advertising Router: 4.4.4.4
LS Seq Number: 80000001
Checksum: 0x8D4
Length: 28
Network Mask: /24
TOS: 0 Metric: 832
Filtre du sous réseau 11.1.1.0/24 :
R4(config)#ip prefix-list TEST deny 11.1.1.0/24
R4(config)#ip prefix-list TEST permit 0.0.0.0/0 le 32
R4(config)#router ospf 1
R4(config-router)#area 2 filter-list prefix TEST in
Vérification :
R5#show ip route 11.1.1.1
% Network not in table
R4#show ip ospf database summary 11.1.1.0
OSPF Router with ID (4.4.4.4) (Process ID 1)
Summary Net Link States (Area 0)
Routing Bit Set on this LSA
LS age: 807
Options: (No TOS-capability, DC, Upward)
LS Type: Summary Links(Network)
Link State ID: 11.1.1.0 (summary Network Number)
Advertising Router: 3.3.3.3
LS Seq Number: 80000001
Checksum: 0x30E2
Length: 28
Network Mask: /24
TOS: 0 Metric: 782
area x filter-list prefix x out
"area x filter-list prefix x out" permet de filtrer les annonces LSA de type 3 sur un ABR.
Le sous réseau 55.5.5.0/24 est présent dans l'area 2 et est diffusé dans l'area 0 par l'ABR R4 (schéma plus haut)
Table de routage de R1 :
R1#show ip route | inc IA
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
O IA 50.5.5.0 [110/203] via 10.1.12.2, 00:16:36, Serial0/0.12
O IA 55.5.5.0 [110/203] via 10.1.12.2, 00:16:36, Serial0/0.12
O IA 5.5.0.0 [110/203] via 10.1.12.2, 00:16:36, Serial0/0.12
O IA 10.1.45.0 [110/202] via 10.1.12.2, 00:16:36, Serial0/0.12
O IA 10.1.34.0 [110/138] via 10.1.12.2, 00:18:47, Serial0/0.12
Filtre du sous réseau 50.5.5.5.0/24 :
R4(config)#ip prefix-list TEST-50 deny 50.5.5.0/24
R4(config)#ip prefix-list TEST-50 permit 0.0.0.0/0 le 32
R4(config)#router ospf 1
R4(config)#area 2 filter-list prefix TEST-50 out
Vérification :
R1#show ip route | inc IA
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
O IA 55.5.5.0 [110/203] via 10.1.12.2, 00:27:21, Serial0/0.12
O IA 5.5.5.0 [110/203] via 10.1.12.2, 00:07:52, Serial0/0.12
O IA 10.1.45.0 [110/202] via 10.1.12.2, 00:27:21, Serial0/0.12
O IA 10.1.34.0 [110/138] via 10.1.12.2, 00:29:32, Serial0/0.12
Autre solution, plus simple, pour ne pas annoncer un réseau :
R4(config)#router ospf 1
R4(config-router)#area 2 range 55.5.5.0 255.255.255.0 not-advertise
distribute-list x out
"distribute-list x out" est utilisé pour filtrer les LAS de type 5 ou 7 (external) sur un ABR.
La commande "area x filter-list prefix" n'a aucun effet sur les routes ospf de type external
Les routeurs de de l'area 0, R3 et R4, des routes externes provenant des annonces OSPF de R5 :
R4#show ip route | inc E2
O E2 50.5.5.0 [110/20] via 10.1.45.5, 00:01:55, Serial0/0.45
O E2 55.5.5.0 [110/20] via 10.1.45.5, 00:01:55, Serial0/0.45
O E2 5.5.5.0 [110/20] via 10.1.45.5, 00:01:55, Serial0/0.45
R3#show ip route ospf | inc E2
O E2 50.5.5.0 [110/20] via 10.1.34.4, 00:02:16, Serial1/0.34
O E2 55.5.5.0 [110/20] via 10.1.34.4, 00:02:16, Serial1/0.34
O E2 5.5.5.0 [110/20] via 10.1.34.4, 00:02:16, Serial1/0.34
Dans le cas des routes externes, le fitre doit être placé sur le routeur en charge de la redistribution avec la commande "distribute-list x out"
Filtre du réseau externe 50.5.5.0 /24 :
R5(config)#access-list 1 deny 50.5.5.0 0.0.0.255
R5(config)#router ospf 1
R5(config-router)#distribute-list 1 out
Vérification :
R3#show ip route ospf | inc E2
O E2 55.5.5.0 [110/20] via 10.1.34.4, 00:08:26, Serial1/0.34
O E2 5.5.5.0 [110/20] via 10.1.34.4, 00:08:26, Serial1/0.34
Autre solution, plus simple, "summary-address" :
R5(config-router)#summary-address 50.5.5.5 255.255.255.0 not-advertise