Route-map
Route-map 能夠控制路由條目,能夠控制路由學不學的到路由。
如上圖所示:
R1(config)#int e0/0
R1(config-if)#ip add 12.12.12.1 255.255.255.0
R1(config-if)#no sh
還有四個環回口
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
R2(config)#int e0/0
R2(config-if)#ip add 12.12.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int e0/1
R2(config-if)#ip add 23.23.23.1 255.255.255.0
R2(config-if)#no sh
R3(config)#int e0/1
R3(config-if)#ip add 23.23.23.2 255.255.255.0
R3(config-if)#no sh
而後在r1上運行rip
R1(config)#router rip
R1(config-router)#no au
R1(config-router)#ver 2
R1(config-router)#net 12.12.12.0
R1(config-router)#net 1.1.1.0
R1(config-router)#net 2.2.2.0
R1(config-router)#net 3.3.3.0
R1(config-router)#net 4.4.4.0
R3上運行ospf
R3(config)#router ospf 111
R3(config-router)#net 23.23.23.0 0.0.0.255 area 0
R2上
R2(config)#router rip
R2(config-router)#no au
R2(config-router)#ver 2
R2(config-router)#net 12.12.12.0
R2(config)#router ospf 111
R2(config-router)#net 23.23.23.0 0.0.0.255 area 0
R2(config-router)#ex
接着在r2上運行重分佈
R2(config)#router ospf 111
R2(config-router)#redistribute rip subnets
R2(config)#router rip
R2(config-router)#redistribute ospf 111 metric 1
咱們的實驗關鍵是route-map 施行路由條目的控制
例如:
咱們只讓r3學習到1.1.1.1 和 2.2.2.2
步驟以下:
咱們先寫下acl
R2(config)#access-list 1 permit 1.1.1.0 0.0.0.255
R2(config)#access-list 1 permit 2.2.2.0 0.0.0.255 只容許1網段和2網段
R2(config)#route-map AAA permit 10 /route-map 的名字是AAA permit 10意思是
指,若是下述match命令後面指定的條件成立的話,則其動做爲容許。
R2(config-route-map)#match ip address 1 /1指的是acl的關鍵字
R2(config)#router ospf 111
R2(config-router)#redistribute rip metric 10 route-map AAA /在路由重布時,引用剛纔配置route-map對重發布的路由進行過濾。
這時候咱們show下r3
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/10] via 23.23.23.1, 00:22:50, Ethernet0/1
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/10] via 23.23.23.1, 00:22:50, Ethernet0/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, Ethernet0/1
只有1和2的網段了。