实验目的:
1、掌握使用指向NULL0接口的静态路由的汇总配置方法。
2、掌握使用聚合属性的路由汇总配置方法。
实验拓扑:
步骤1:接口ip配置:
R1(config)#interface f0/0
R1(config-if)#ip address 12.12.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.0.1 255.255.255.0
R1(config-if)#interface loopback 1
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#interface loopback 2
R1(config-if)#ip address 1.1.2.1 255.255.255.0
R1(config-if)#interface loopback 3
R1(config-if)#ip address 1.1.3.1 255.255.255.0
R2(config)#interface f0/0
R2(config-if)#ip address 12.12.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface f0/1
R2(config-if)#ip address 23.23.23.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#interface f0/1
R3(config-if)#ip address 23.23.23.3 255.255.255.0
R3(config-if)#no shutdown
步骤2:配置各路由器的邻居关系、主网络宣告。配置如下:
R1(config)#router bgp 1
R1(config-router)#neighbor 12.12.12.2 remote-as 1
R1(config-router)#network 12.12.12.0 mask 255.255.255.0
R1(config-router)#neighbor 23.23.23.3 remote-as 2
R1(config-router)#network 1.1.0.0 mask 255.255.255.0
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R1(config-router)#network 1.1.2.0 mask 255.255.255.0
R1(config-router)#network 1.1.3.0 mask 255.255.255.0
R1(config-router)#neighbor 23.23.23.3 ebgp-multihop 3
R2(config)#router bgp 1
R2(config-router)#neighbor 12.12.12.1 remote-as 1
R2(config-router)#network 12.12.12.0 mask 255.255.255.0
R2(config-router)#neighbor 23.23.23.3 remote-as 2
R2(config-router)#network 23.23.23.0 mask 255.255.255.0
R2(config-router)#neighbor 23.23.23.3 ebgp-multihop 2
R3(config)#router bgp 2
R3(config-router)#neighbor 12.12.12.1 remote-as 1
R3(config-router)#neighbor 23.23.23.2 remote-as 1
R3(config-router)#network 23.23.23.0 mask 255.255.255.0
R3(config-router)#neighbor 12.12.12.1 ebgp-multihop 3
R3(config-router)#neighbor 23.23.23.2 ebgp-multihop 2
在R2上观察BGP的邻居关系状态:
R2#show ip bgp summary
BGP router identifier 23.23.23.2, local AS number 1
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.12.12.1 4 1 5 5 1 0 0 00:02:19 0
23.23.23.3 4 2 9 9 1 0 0 00:00:05 0
查看R1的BGP的协议属性:
R1#show ip protocols
Routing Protocol is "bgp 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
//同步规则默认是禁用的。
//注意:在低于12.3以下IOS的版下,同步规则默认是启用的。
IGP synchronization is disabled
//自动汇总属性默认是禁用的。
//注意:在低于12.2以下的IOS的版上,自动汇总是默认启用的。
Automatic route summarization is disabled
Neighbor(s):
Address FiltIn FiltOut DistIn DistOut Weight RouteMap
12.12.12.2
Maximum path: 1
Routing Information Sources:
Gateway Distance Last Update
Distance: external 20 internal 200 local 200
查看R3路由表信息:
R3#show ip route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 4 subnets
B 1.1.0.0 [20/0] via 23.23.23.2, 00:18:57
B 1.1.1.0 [20/0] via 23.23.23.2, 00:19:28
B 1.1.2.0 [20/0] via 23.23.23.2, 00:18:57
B 1.1.3.0 [20/0] via 23.23.23.2, 00:18:57
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [20/0] via 23.23.23.2, 00:28:51
以通过路由汇总配置,有效的减少路由表的大小,提高路由效率。因此在R1路由器作如下的配置:
R1(config)#ip route 1.1.0.0 255.255.0.0 null 0
R1(config)#router bgp 1
R1(config-router)#network 1.1.0.0 mask 255.255.0.0
查看R3路由表:
R3#show ip route
Gateway of last resort is not set
1.0.0.0/8 is variably subnetted, 6 subnets, 3 masks
B 1.1.0.0/24 [20/0] via 23.23.23.2, 00:21:39
B 1.1.0.0/16 [20/0] via 23.23.23.2, 00:00:54
// 此时R3路由已经可以学习到被汇总的路由。
B 1.1.1.0/24 [20/0] via 23.23.23.2, 00:22:09
B 1.0.0.0/8 [20/0] via 23.23.23.2, 00:01:25
B 1.1.2.0/24 [20/0] via 23.23.23.2, 00:21:39
B 1.1.3.0/24 [20/0] via 23.23.23.2, 00:21:39
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [20/0] via 23.23.23.2, 00:31:33
BGP的network命令与OSPF或是其它的IGP不同的是:BGP当检测到本地有network命令,首先BGP会检查本地路由表,查看是否此条路由存在,如果有,则将此条路由通告给对等体,否则忽略此条network命令。
步骤3:另外需要注意的是,虽然在R3学习了/22位子网汇总路由,但是其它的/24位网络具体路由也同时出现的路由表,因此还需要在R1上作如下配置:
R1(config)#router bgp 1
R1(config-router)#no network 1.1.0.0 mask 255.255.255.0
R1(config-router)#no network 1.1.1.0 mask 255.255.255.0
R1(config-router)#no network 1.1.2.0 mask 255.255.255.0
R1(config-router)#no network 1.1.3.0 mask 255.255.255.0
查看R2路由表:
R3#show ip route
Gateway of last resort is not set
1.0.0.0/16 is subnetted, 1 subnets
B 1.1.0.0 [20/0] via 23.23.23.2, 00:09:57
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [20/0] via 23.23.23.2, 00:09:57
测试汇总路由有效性:
R3#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/24/32 ms
虽然通过指向NULL 0口的路由进行配置BGP的汇总非常的简单,而且易于理解,但是不利于排错,因为其它BGP的路由器无法获知路由在何处汇总的。因此,建议使用BGP的聚合方法进行配置汇总。
步骤4:在R1上将的指向NULL 0的接口静态路由和BGP的下的针对指向NULL 0口的静态路由的宣告给no掉。同时,在R1上将四个回环口的子网重新network宣告。
R1(config)#no ip route 1.1.0.0 255.255.0.0 null 0
R1(config)#router bgp 1
R1(config-router)#network 1.1.0.0 mask 255.255.255.0
R1(config-router)#network 1.1.1.0 mask 255.255.255.0
R1(config-router)#network 1.1.2.0 mask 255.255.255.0
R1(config-router)#network 1.1.3.0 mask 255.255.255.0
步骤5:在R1路由器实施聚合的配置:
R1(config)#router bgp 1
R1(config-router)#aggregate-address 1.1.0.0 255.255.0.0 summary-only
//对172.16.0.0的四个24位子网路由汇总成一条172.16.0.0/22位的汇总路由。
//summary-only的主要目的是,仅发送汇总路由,而不发送具体路由。
查看R3路由表:
R3#show ip route
Gateway of last resort is not set
1.0.0.0/16 is subnetted, 1 subnets
B 1.1.0.0 [20/0] via 23.23.23.2, 00:01:39
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [20/0] via 23.23.23.2, 00:24:37
查看汇总路由的属性:
R3#show ip bgp 1.1.0.0
BGP routing table entry for 1.1.0.0/16, version 11
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1
1, (aggregated by 1 1.1.3.1)
12.12.12.1 from 12.12.12.1 (1.1.3.1)
Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate
//聚合者属性显示了谁聚合了此条路由。
//此处显示是由:1自治系统的12.12.12.1聚合了此条路由。12.12.12.1为路由ID。
1, (aggregated by 1 1.1.3.1)
23.23.23.2 from 23.23.23.2 (23.23.23.2)
Origin IGP, localpref 100, valid, external, atomic-aggregate, best
测试汇总路由有效性:
R3#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/37/68 ms