Objectives:
-、配置EIGRP和OSPF
-、实现EIGRP和OSPF的双向重分配
-、实现EIGRP的路由
-、使用route map实现路由过滤
-、修改EIGRP和OSPF的AD值
-、在EIGRP上创建被动接口
-、在OSPF的ABR和ASBR上配置路由汇总
首先在R1,R2,R3上把基本的配置配好
R1#show ip int bri | b Serial
Serial1/0 172.16.12.1 YES manual up up
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
Loopback0 172.16.1.1 YES manual up up
Loopback48 192.168.48.1 YES manual up up
Loopback49 192.168.49.1 YES manual up up
Loopback50 192.168.50.1 YES manual up up
Loopback51 192.168.51.1 YES manual up up
Loopback70 192.168.70.1 YES manual up up
R2(config-if)#do show ip int bri | b Serial
Serial1/0 unassigned YES unset administratively down down
Serial1/1 172.16.12.2 YES manual up up
Serial1/2 unassigned YES unset administratively down down
Serial1/3 172.16.23.2 YES manual up up
Loopback0 172.16.2.1 YES manual up up
Loopback100 172.16.100.1 YES manual up up
R3(config-if)#do show ip int bri | b Serial
Serial1/0 172.16.23.3 YES manual up up
Serial1/1 unassigned YES unset administratively down down
Serial1/2 unassigned YES unset administratively down down
Serial1/3 unassigned YES unset administratively down down
Loopback0 172.16.3.1 YES manual up up
Loopback8 192.168.8.1 YES manual up up
Loopback9 192.168.9.1 YES manual up up
Loopback10 192.168.10.1 YES manual up up
Loopback11 192.168.11.1 YES manual up up
Loopback20 192.168.20.1 YES manual up up
Loopback25 192.168.25.1 YES manual up up
Loopback30 192.168.30.1 YES manual up up
Loopback35 192.168.35.1 YES manual up up
Loopback40 192.168.40.1 YES manual up up
完成基本配置后,在R2上验证一下
R2#ping 172.16.12.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/96/216 ms
R2#ping 172.16.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/99/260 ms
OK,进入下一个环节,开始配置EIGRP和OSPF(小激动一下,因为公司一大驼累人的事,一个星期没做过实验)。按照拓扑的要求进行路由协议的配置,先在R1和R2上配置EIGRP
R1#show runn | b r e
router eigrp 1
network 0.0.0.0
no auto-summary
!
R2(config-router)#do show runn | b r e
router eigrp 1
network 172.16.0.0
no auto-summary
!
看一下R1上面EIGRP的network,纯属懒人做法(除实验平台外请勿使用),再看一下R2的network 172.16.0.0,宜告一个主类网络,这样将会把R2上的所有172.16.0.0/16的网络加入到EIGRP,下面来验证一下
首先
R2(config-router)#do show ip eigrp nei
IP-EIGRP neighbors for process 1
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 172.16.12.1 Se1/1 11 00:13:15 113 1017 0 3
邻居关系可以成功建立,
R1#show ip eigrp int 1
IP-EIGRP interfaces for process 1
Xmit Queue Mean Pacing Time Multicast Pending
Interface Peers Un/Reliable SRTT Un/Reliable Flow Timer Routes
Se1/0 1 0/0 160 0/15 695 0
Lo0 0 0/0 0 0/1 0 0
Lo48 0 0/0 0 0/1 0 0
Lo49 0 0/0 0 0/1 0 0
Lo50 0 0/0 0 0/1 0 0
Lo51 0 0/0 0 0/1 0 0
Lo70 0 0/0 0 0/1 0 0
R1上把所有的接口都加入到EIGRP,看一下R2的
R2(config-router)#do show ip eigrp int 1
IP-EIGRP interfaces for process 1
Xmit Queue Mean Pacing Time Multicast Pending
Interface Peers Un/Reliable SRTT Un/Reliable Flow Timer Routes
Se1/1 1 0/0 113 0/15 467 0
Se1/3 0 0/0 0 0/1 0 0
Lo0 0 0/0 0 0/1 0 0
Lo100 0 0/0 0 0/1 0 0
跟意料中的一样。但是在R1可以在network后面加上反掩码,使得通告更加精确,如:
R1#show runn | b r e
router eigrp 1
network 172.16.1.0 0.0.0.255
network 172.16.12.0 0.0.0.255
network 192.168.48.0
network 192.168.49.0
network 192.168.50.0
network 192.168.51.0
network 192.168.70.0
no auto-summary
!
还有就是no auto-summary,有事没事把它带上,总不会让你吃亏,作用你们明白的… 接下面验证一下,R1和R2上的路由是否都正确
R1#show ip route eigrp
172.16.0.0/24 is subnetted, 5 subnets
D 172.16.23.0 [90/2681856] via 172.16.12.2, 00:32:51, Serial1/0
D 172.16.2.0 [90/2297856] via 172.16.12.2, 00:32:51, Serial1/0
D 172.16.100.0 [90/2297856] via 172.16.12.2, 00:32:51, Serial1/0
R2#show ip route eigrp
172.16.0.0/24 is subnetted, 5 subnets
D 172.16.1.0 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
D 192.168.51.0/24 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
D 192.168.50.0/24 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
D 192.168.49.0/24 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
D 192.168.70.0/24 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
D 192.168.48.0/24 [90/2297856] via 172.16.12.1, 00:32:57, Serial1/1
R2#
R1通过EIGRP从R2那学习到3条路由,正确。R2通过EIGRP从R1学习到6条路由,其中掩码,下一跳,出接口都没有问题,正确。
但是从上面的
R1#show ip eigrp int 1
IP-EIGRP interfaces for process 1
Xmit Queue Mean Pacing Time Multicast Pending
Interface Peers Un/Reliable SRTT Un/Reliable Flow Timer Routes
Se1/0 1 0/0 160 0/15 695 0
Lo0 0 0/0 0 0/1 0 0
Lo48 0 0/0 0 0/1 0 0
Lo49 0 0/0 0 0/1 0 0
Lo50 0 0/0 0 0/1 0 0
Lo51 0 0/0 0 0/1 0 0
Lo70 0 0/0 0 0/1 0 0
R1#
R2#show ip eigrp int 1
IP-EIGRP interfaces for process 1
Xmit Queue Mean Pacing Time Multicast Pending
Interface Peers Un/Reliable SRTT Un/Reliable Flow Timer Routes
Se1/1 1 0/0 113 0/15 467 0
Se1/3 0 0/0 0 0/1 0 0
Lo0 0 0/0 0 0/1 0 0
Lo100 0 0/0 0 0/1 0 0
R2#
EIGRP会在R1和R2的环回口和R2的S1/3接口发送EIGRP的HELLO包,这是没有必要的,所以优化一下下,看一下配置
R1(config-router)#do show runn | b r e
router eigrp 1
passive-interface default
no passive-interface Serial1/0
network 0.0.0.0
no auto-summary
!
R2(config-router)#do show runn | b r e
router eigrp 1
passive-interface default
no passive-interface Serial1/1
network 172.16.0.0
no auto-summary
!
在R1上把直接R2的串口以外的接口配置为被动接口,在R2上把直连R1的串口以外的接口配置为被动接口,验证一下
R1(config-router)#do show ip pro
Routing Protocol is "eigrp 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Default networks flagged in outgoing updates
Default networks accepted from incoming updates
EIGRP metric weight K1=1, K2=0, K3=1, K4=0, K5=0
EIGRP maximum hopcount 100
EIGRP maximum metric variance 1
Redistributing: eigrp 1
EIGRP NSF-aware route hold timer is 240s
Automatic network summarization is not in effect
Maximum path: 4
Routing for Networks:
0.0.0.0
Passive Interface(s):
Ethernet0/0
Ethernet0/1
Ethernet0/2
Ethernet0/3
Serial1/1
Serial1/2
Serial1/3
Loopback0
Passive Interface(s):
Loopback48
Loopback49
Loopback50
Loopback51
Loopback70
VoIP-Null0
Routing Information Sources:
Gateway Distance Last Update
172.16.12.2 90 00:02:13
Distance: internal 90 external 170
R1#show ip eigrp int 1
IP-EIGRP interfaces for process 1
Xmit Queue Mean Pacing Time Multicast Pending
Interface Peers Un/Reliable SRTT Un/Reliable Flow Timer Routes
Se1/0 1 0/0 174 0/15 727 0
R1#
当然在R2上把连接到R3的串口配置成为被动接口还会起到一定的安全作用。查看一下R2的路由表
R2#show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 5 subnets
C 172.16.23.0 is directly connected, Serial1/3
C 172.16.12.0 is directly connected, Serial1/1
D 172.16.1.0 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
C 172.16.2.0 is directly connected, Loopback0
C 172.16.100.0 is directly connected, Loopback100
D 192.168.51.0/24 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
D 192.168.50.0/24 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
D 192.168.49.0/24 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
D 192.168.70.0/24 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
D 192.168.48.0/24 [90/2297856] via 172.16.12.1, 00:09:45, Serial1/1
可以将172.16.48.0/24-172.16.51.0/24汇总成172.16.48.0/23,也就是在可以在R1配置EIGRP的路由汇总。EIGRP的路由汇总是配置在接口下面的,不像RIP和OSPF,还有RIP也不可以进行超网的路由汇总(请看上一篇RIP和OSPF的重分配)。
R1(config-if)#do show runn int s1/0
Building configuration...
Current configuration : 146 bytes
!
interface Serial1/0
ip address 172.16.12.1 255.255.255.0
ip summary-address eigrp 1 192.168.48.0 255.255.252.0 5
serial restart-delay 0
end
这将在R1的路由表中产生一条指向空接口的汇总路由,还有在R2上将学习到这条汇总路由,验证一下
R1#show ip rou
R1#show ip route eigrp
172.16.0.0/24 is subnetted, 5 subnets
D 172.16.23.0 [90/2681856] via 172.16.12.2, 00:01:14, Serial1/0
D 172.16.2.0 [90/2297856] via 172.16.12.2, 00:01:14, Serial1/0
D 172.16.100.0 [90/2297856] via 172.16.12.2, 00:01:14, Serial1/0
D 192.168.48.0/22 is a summary, 00:00:18, Null0
R2#show ip route eigrp
172.16.0.0/24 is subnetted, 5 subnets
D 172.16.1.0 [90/2297856] via 172.16.12.1, 00:01:44, Serial1/1
D 192.168.70.0/24 [90/2297856] via 172.16.12.1, 00:01:44, Serial1/1
D 192.168.48.0/22 [90/2297856] via 172.16.12.1, 00:00:48, Serial1/1
正确,但要注意看掩码后面的5,它是管理距离,也就是EIGRP的汇总路由的默认管理距离是5,但是它只是在本地有效,查看一下
R1#show ip route 192.168.48.0 255.255.252.0
Routing entry for 192.168.48.0/22, supernet
Known via "eigrp 1", distance 5, metric 128256, type internal
Redistributing via eigrp 1
Routing Descriptor Blocks:
* directly connected, via Null0
Route metric is 128256, traffic share count is 1
Total delay is 5000 microseconds, minimum bandwidth is 10000000 Kbit
Reliability 255/255, minimum MTU 1514 bytes
Loading 1/255, Hops 0
R2#show ip route 192.168.48.0 255.255.252.0
Routing entry for 192.168.48.0/22, supernet
Known via "eigrp 1", distance 90, metric 2297856, type internal
Redistributing via eigrp 1
Last update from 172.16.12.1 on Serial1/1, 00:04:19 ago
Routing Descriptor Blocks:
* 172.16.12.1, from 172.16.12.1, 00:04:19 ago, via Serial1/1
Route metric is 2297856, traffic share count is 1
Total delay is 25000 microseconds, minimum bandwidth is 1544 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 1
EIGRP配置完成后,在R2和R3上配置OSPF。R2和R3之间的串行链路在区域0,R2的Loopback100在区域10,R3的Lo~Lo11在区域20。
R2#show runn | b r o
router ospf 1
router-id 1.1.1.2
log-adjacency-changes
network 172.16.23.0 0.0.0.255 area 0
network 172.16.100.0 0.0.0.255 area 10
!
R3#show runn | b r o
router ospf 1
router-id 1.1.1.3
log-adjacency-changes
network 172.16.3.0 0.0.0.255 area 0
network 172.16.23.0 0.0.0.255 area 0
network 192.168.8.0 0.0.0.255 area 20
network 192.168.9.0 0.0.0.255 area 20
network 192.168.10.0 0.0.0.255 area 20
network 192.168.11.0 0.0.0.255 area 20
network 192.168.20.0 0.0.0.255 area 0
network 192.168.25.0 0.0.0.255 area 0
network 192.168.30.0 0.0.0.255 area 0
network 192.168.35.0 0.0.0.255 area 0
network 192.168.40.0 0.0.0.255 area 0
!
配置完成后,应该是R2和R3完成邻接关系,由于是点到点的网络类型,所以没有DR和BDR的选举。R2可以学习到R3的环回地址路由和区域20的O IA路由,还有就是R3可以学习到区域10的O IA路由,下面验证一下
R2#show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
1.1.1.3 0 FULL/ - 00:00:31 172.16.23.3 Serial1/3
R3#show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
1.1.1.2 0 FULL/ - 00:00:30 172.16.23.2 Serial1/0
下面是路由表
R2#show ip route ospf
192.168.30.0/32 is subnetted, 1 subnets
O 192.168.30.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.8.0/32 is subnetted, 1 subnets
O IA 192.168.8.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.25.0/32 is subnetted, 1 subnets
O 192.168.25.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.9.0/32 is subnetted, 1 subnets
O IA 192.168.9.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.10.0/32 is subnetted, 1 subnets
O IA 192.168.10.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.40.0/32 is subnetted, 1 subnets
O 192.168.40.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
172.16.0.0/16 is variably subnetted, 6 subnets, 2 masks
O 172.16.3.1/32 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.11.0/32 is subnetted, 1 subnets
O IA 192.168.11.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.20.0/32 is subnetted, 1 subnets
O 192.168.20.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
192.168.35.0/32 is subnetted, 1 subnets
O 192.168.35.1 [110/65] via 172.16.23.3, 00:04:12, Serial1/3
R3#show ip route ospf
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
O IA 172.16.100.1/32 [110/65] via 172.16.23.2, 00:04:31, Serial1/0
邻接关系可以形成,路由也可以学习到,再看清楚一点
O IA 172.16.100.1/32 [110/65] via 172.16.23.2, 00:04:31, Serial1/0
/32的主机路由,为什么呢?
R3#show ip ospf int lo 0
Loopback0 is up, line protocol is up
Internet Address 172.16.3.1/24, Area 0
Process ID 1, Router ID 1.1.1.3, Network Type LOOPBACK, Cost: 1
Loopback interface is treated as a stub Host
OSPF把环回接口当作一个末梢的主机,把它改为/24的可以,
R2#show runn int lo 100
Building configuration...
Current configuration : 100 bytes
!
interface Loopback100
ip address 172.16.100.1 255.255.255.0
ip ospf network point-to-point
end
R3#show ip route ospf
172.16.0.0/24 is subnetted, 3 subnets
O IA 172.16.100.0 [110/65] via 172.16.23.2, 00:00:31, Serial1/0
这下正确了。但是在show runn | b r o的时候有没有注意到log-adjacency-changes,想知道它的作用吧,在OSPF进程下面打个问号问一下
R2(config)#router ospf 1
R2(config-router)#?
Router configuration commands:
log-adjacency-changes Log changes in adjacency state
也就是在邻接关系发生改变的时候会有日志提示,当然这是默认的配置,如果把它关掉你可能把OSPF配好了,就会在傻等它loading to full,可是路由器一直没有提示…
R2(config-router)#no log-adjacency-changes
R2(config-router)#do clear ip ospf pro
Reset ALL OSPF processes? [no]: y
R2(config-router)#do show ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
1.1.1.3 0 FULL/ - 00:00:34 172.16.23.3 Serial1/3
嘿嘿,看到了吧。
观察一下R2的路由表
R2#show ip route ospf
192.168.30.0/32 is subnetted, 1 subnets
O 192.168.30.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.8.0/32 is subnetted, 1 subnets
O IA 192.168.8.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.25.0/32 is subnetted, 1 subnets
O 192.168.25.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.9.0/32 is subnetted, 1 subnets
O IA 192.168.9.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.10.0/32 is subnetted, 1 subnets
O IA 192.168.10.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.40.0/32 is subnetted, 1 subnets
O 192.168.40.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
172.16.0.0/24 is subnetted, 6 subnets
O 172.16.3.0 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.11.0/32 is subnetted, 1 subnets
O IA 192.168.11.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.20.0/32 is subnetted, 1 subnets
O 192.168.20.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
192.168.35.0/32 is subnetted, 1 subnets
O 192.168.35.1 [110/65] via 172.16.23.3, 01:24:34, Serial1/3
OSPF的路由汇总可以发生在ABR和ASBR上,当然可以把区域20的路由在R3上汇总,下面试一下
R3(config-router)#do show runn | b r o
router ospf 1
router-id 1.1.1.3
log-adjacency-changes
area 20 range 192.168.8.0 255.255.252.0
… …
想像一下配置完成后的结果:在R3上会产生一条指向空接口的汇总路由,之后在R2上会看到一条192.168.8.0/22的O IA路由。其3类LSA的传递过程应该是,R3向R2发送192.168.8.0/24~192.168.11.0/24的3类LSA,但是其中的age字段为3600S,这样R2在收到这些LSA的时候会让它老化掉,接着R3再向R2发送汇总后的3类LSA。当然在R2上的明细路由会由于3类LSA的老化而删除。下面在R3和R2上验证一下
R3(config-router)#do show ip route ospf
172.16.0.0/24 is subnetted, 3 subnets
O IA 172.16.100.0 [110/65] via 172.16.23.2, 00:10:01, Serial1/0
O 192.168.8.0/22 is a summary, 00:10:01, Null0
R2#show ip ospf data
OSPF Router with ID (1.1.1.2) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.2 1.1.1.2 2003 0x80000004 0x00885E 2
1.1.1.3 1.1.1.3 46 0x80000005 0x0031E1 8
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
172.16.100.0 1.1.1.2 2003 0x80000003 0x00957E
192.168.8.0 1.1.1.3 655 0x80000001 0x005077
R2#show ip route ospf
192.168.30.0/32 is subnetted, 1 subnets
O 192.168.30.1 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
192.168.25.0/32 is subnetted, 1 subnets
O 192.168.25.1 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
192.168.40.0/32 is subnetted, 1 subnets
O 192.168.40.1 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
172.16.0.0/24 is subnetted, 6 subnets
O 172.16.3.0 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
192.168.20.0/32 is subnetted, 1 subnets
O 192.168.20.1 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
192.168.35.0/32 is subnetted, 1 subnets
O 192.168.35.1 [110/65] via 172.16.23.3, 01:41:31, Serial1/3
O IA 192.168.8.0/22 [110/65] via 172.16.23.3, 00:11:35, Serial1/3
在此可以对比一下EIGRP和OSPF的汇总。比如EIGRP和OSPF路由汇总是配置在哪,为什么要在这些位置配置。
为了实现整个网络的互联,可以在R2上配置路由重分配
R2#show runn | b r e
router eigrp 1
redistribute ospf 1 metric 10000 100 255 1 1500
passive-interface default
no passive-interface Serial1/1
network 172.16.0.0
no auto-summary
!
router ospf 1
router-id 1.1.1.2
no log-adjacency-changes
redistribute eigrp 1 subnets
network 172.16.23.0 0.0.0.255 area 0
network 172.16.100.0 0.0.0.255 area 10
!
在EIGRP进程下重分布时,需要指定度量值,如果没有指定度量值,那么默认度量值将会是无穷大,除非你使用default-metric。在OSPF进程下重分布EIGRP和RIP时要注意加上subnets,如果没有加上它只能重分布主类网络,当然OSPF的默认重分布的度量值为20,类型为O E2,在R1和R3上验证一下
R1#show ip route eigrp
192.168.30.0/32 is subnetted, 1 subnets
D EX 192.168.30.1 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
192.168.25.0/32 is subnetted, 1 subnets
D EX 192.168.25.1 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
192.168.40.0/32 is subnetted, 1 subnets
D EX 192.168.40.1 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
172.16.0.0/24 is subnetted, 6 subnets
D 172.16.23.0 [90/2681856] via 172.16.12.2, 02:09:20, Serial1/0
D 172.16.2.0 [90/2297856] via 172.16.12.2, 02:09:20, Serial1/0
D EX 172.16.3.0 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
D 172.16.100.0 [90/2297856] via 172.16.12.2, 02:09:20, Serial1/0
192.168.20.0/32 is subnetted, 1 subnets
D EX 192.168.20.1 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
192.168.35.0/32 is subnetted, 1 subnets
D EX 192.168.35.1 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
D EX 192.168.8.0/22 [170/2195456] via 172.16.12.2, 00:06:07, Serial1/0
D 192.168.48.0/22 is a summary, 02:09:21, Null0
R3#show ip route ospf
172.16.0.0/24 is subnetted, 6 subnets
O E2 172.16.12.0 [110/20] via 172.16.23.2, 00:06:15, Serial1/0
O E2 172.16.1.0 [110/20] via 172.16.23.2, 00:06:15, Serial1/0
O E2 172.16.2.0 [110/20] via 172.16.23.2, 00:06:15, Serial1/0
O IA 172.16.100.0 [110/65] via 172.16.23.2, 00:06:15, Serial1/0
O E2 192.168.70.0/24 [110/20] via 172.16.23.2, 00:06:15, Serial1/0
O 192.168.8.0/22 is a summary, 00:39:39, Null0
O E2 192.168.48.0/22 [110/20] via 172.16.23.2, 00:06:15, Serial1/0
结果正确。但是现在有一个新的需要,不让R3上的192.168.25.0/24和192.168.30.0/24的路由重分布到R1上。呵呵,可以使用route-map实现
先在R2上定义好访问控制列表
R2(config)#do show runn | b ip access
ip access-list standard o2e
permit 192.168.25.0 0.0.0.255
permit 192.168.30.0 0.0.0.255
!
然后配置route-map
R2(config)#do show runn | b route-map
route-map deny_o deny 10
match ip address o2e
!
route-map deny_o permit 20
!
之后应用在EIGRP重分布下面
R2#show runn | b r e
router eigrp 1
redistribute ospf 1 metric 10000 100 255 1 1500 route-map deny_o
在R1那里验证一下
R1#show ip route eigrp
192.168.40.0/32 is subnetted, 1 subnets
D EX 192.168.40.1 [170/2195456] via 172.16.12.2, 00:03:15, Serial1/0
172.16.0.0/24 is subnetted, 6 subnets
D 172.16.23.0 [90/2681856] via 172.16.12.2, 00:04:55, Serial1/0
D 172.16.2.0 [90/2297856] via 172.16.12.2, 00:04:55, Serial1/0
D EX 172.16.3.0 [170/2195456] via 172.16.12.2, 00:03:15, Serial1/0
D 172.16.100.0 [90/2297856] via 172.16.12.2, 00:04:55, Serial1/0
192.168.20.0/32 is subnetted, 1 subnets
D EX 192.168.20.1 [170/2195456] via 172.16.12.2, 00:03:15, Serial1/0
192.168.35.0/32 is subnetted, 1 subnets
D EX 192.168.35.1 [170/2195456] via 172.16.12.2, 00:03:15, Serial1/0
D EX 192.168.8.0/22 [170/2195456] via 172.16.12.2, 00:03:15, Serial1/0
D 192.168.48.0/22 is a summary, 00:04:55, Null0
成功了!!!
前面有说到OSPF可以在ABR和ASBR上进行路由汇总。在R2上进行了双向的分布后,R2成为了ASBR,也就是现在可以在R2上对重分布的路由进行路由汇总。分析一下,在R1的环回口上的IP地址192.168.48.0/24-192.168.51.0/24可以汇总成192.168.48.0/22,还有在前面已经在R1的串口上配置的EIGRP的路由汇总,现在把它NO掉,之后再在R2上进行OSPF的路由汇总,看一下OSPF在ASBR上是怎样进行路由汇总的
R1(config-if)#no ip summary-address eigrp 1 192.168.48.0 255.255.252.0
然后在R2上进行路由汇总
R2(config-router)#do show runn | b r o
router ospf 1
router-id 1.1.1.2
no log-adjacency-changes
summary-address 192.168.48.0 255.255.252.0
在R3上对比一下路由表
R3#show ip route ospf
172.16.0.0/24 is subnetted, 6 subnets
O E2 172.16.12.0 [110/20] via 172.16.23.2, 01:08:08, Serial1/0
O E2 172.16.1.0 [110/20] via 172.16.23.2, 01:08:08, Serial1/0
O E2 172.16.2.0 [110/20] via 172.16.23.2, 01:08:08, Serial1/0
O IA 172.16.100.0 [110/65] via 172.16.23.2, 01:08:08, Serial1/0
O E2 192.168.51.0/24 [110/20] via 172.16.23.2, 00:00:10, Serial1/0
O E2 192.168.50.0/24 [110/20] via 172.16.23.2, 00:00:10, Serial1/0
O E2 192.168.49.0/24 [110/20] via 172.16.23.2, 00:00:10, Serial1/0
O E2 192.168.70.0/24 [110/20] via 172.16.23.2, 01:08:08, Serial1/0
O E2 192.168.48.0/24 [110/20] via 172.16.23.2, 00:00:10, Serial1/0
O 192.168.8.0/22 is a summary, 01:41:31, Null0
R3#show ip route ospf
172.16.0.0/24 is subnetted, 6 subnets
O E2 172.16.12.0 [110/20] via 172.16.23.2, 01:10:21, Serial1/0
O E2 172.16.1.0 [110/20] via 172.16.23.2, 01:10:21, Serial1/0
O E2 172.16.2.0 [110/20] via 172.16.23.2, 01:10:21, Serial1/0
O IA 172.16.100.0 [110/65] via 172.16.23.2, 01:10:21, Serial1/0
O E2 192.168.70.0/24 [110/20] via 172.16.23.2, 01:10:21, Serial1/0
O 192.168.8.0/22 is a summary, 01:43:45, Null0
O E2 192.168.48.0/22 [110/20] via 172.16.23.2, 00:01:27, Serial1/0
有效果了吧。OSPF的两种汇总使用的命令是不同的,area * range ***和summary-address ***
最后就是修改管理距离,直接在路由协议进程下,使用distance *** 就OK了!!!