重分布即使将一种协议引入到另外一种协议中,为什么会出现这种技术,我想大慨是实际网络中不会是完美规划,会出现各种各样的路由协议,而你又不能改变(或者改变代价太大),而且需要互相通信吧。
重分布最主要的问题就是管理距离(administrative distance )与度量值(metric),4大igp协议metric有各自的算法,而管理距离也不相同,不同的协议如何进行路由学习呢,那就redistribute吧
重分布分为3种形式:
a协议-》b协议(在将isis重分布进入其他协议,直连网段不会被重分布进去,这个大慨是isis的bug吧)
static-》b协议
connected-》b协议
静态与直连重分布进协议都是不需要手动添加metric值的,都为1.
而其他协议呢,有一个默认初始度量值(default seed metric)
eigrp 无限大(这个就不好比喻了)
rip 无限大(16hop,rip16跳为不可达)
ospf 20(cost=20)
isis 0
既然metric不同,那只有redistribute时手动添加可以计算metric值
redistribute属于路由的入流向,他属于control层面
图中r0与r1既运行ospf又运行rip协议,而r2只运行rip,r3只运行ospf,而r0与r1对于ospf来说就是ASBR了,实验中将rip重分布进ospf,ospf重分布到rip,并且在r0与r1两点上都进行重分布。形成2点双向的重分布。
r0与r2是13.1.1.0/24网段
r0与r3是14.1.1.0/24网段
r1与r2是23.1.1.0/24网段
r1与r3是24.1.1.0/24网段
每个router上面开一个loopback接口
r0为1.1.1.1
r1为2.2.2.2
r2为3.3.3.3
r3为4.4.4.4
文中rx 都是图中的rx
配置我就不一步一步的敲了,直接上传配置了
R0的配置:
- !
- version 12.4
- service timestamps debug datetime msec
- service timestamps log datetime msec
- no service password-encryption
- !
- hostname R1
- !
- boot-start-marker
- boot-end-marker
- !
- no aaa new-model
- memory-size iomem 5
- !
- ip cef
- no ip domain lookup
- !
- interface Loopback0
- ip address 1.1.1.1 255.255.255.0
- !
- interface Serial0/0
- ip address 13.1.1.1 255.255.255.0
- serial restart-delay 0
- clock rate 128000
- !
- interface Serial0/1
- ip address 14.1.1.1 255.255.255.0
- serial restart-delay 0
- clock rate 128000
- !
- interface Serial0/2
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/3
- no ip address
- shutdown
- serial restart-delay 0
- !
- router ospf 110
- router-id 1.1.1.1
- log-adjacency-changes
- redistribute rip subnets
- network 14.1.1.0 0.0.0.255 area 0
- distance 121 2.2.2.2 0.0.0.0 1
- !
- router rip
- version 2
- redistribute ospf 110 metric 1
- passive-interface Loopback0
- network 1.0.0.0
- network 13.0.0.0
- no auto-summary
- !
- ip http server
- no ip http secure-server
- !
- access-list 1 permit 3.3.3.0
- access-list 1 permit 23.1.1.0
- access-list 1 permit 13.1.1.0
- !
- control-plane
- !
- line con 0
- exec-timeout 0 0
- logging synchronous
- line aux 0
- line vty 0 4
- !
- !
- end
R1的配置:
- !
- version 12.4
- service timestamps debug datetime msec
- service timestamps log datetime msec
- no service password-encryption
- !
- hostname R2
- !
- boot-start-marker
- boot-end-marker
- !
- no aaa new-model
- memory-size iomem 5
- !
- ip cef
- no ip domain lookup
- !
- interface Loopback0
- ip address 2.2.2.2 255.255.255.0
- !
- interface Serial0/0
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/1
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/2
- ip address 23.1.1.2 255.255.255.0
- serial restart-delay 0
- clock rate 128000
- !
- interface Serial0/3
- ip address 24.1.1.2 255.255.255.0
- serial restart-delay 0
- clock rate 128000
- !
- router ospf 110
- router-id 2.2.2.2
- log-adjacency-changes
- redistribute rip subnets route-map OSPF
- passive-interface Loopback0
- network 2.2.2.0 0.0.0.255 area 0
- network 24.1.1.0 0.0.0.255 area 0
- distance 121 1.1.1.1 0.0.0.0 1
- !
- router rip
- version 2
- redistribute ospf 110 route-map RED
- network 23.0.0.0
- no auto-summary
- !
- ip http server
- no ip http secure-server
- !
- access-list 1 permit 3.3.3.0
- access-list 1 permit 23.1.1.0
- access-list 1 permit 13.1.1.0
- !
- ip prefix-list 1 seq 5 permit 24.1.1.0/24
R2的配置:
- !
- version 12.4
- service timestamps debug datetime msec
- service timestamps log datetime msec
- no service password-encryption
- !
- hostname R3
- !
- boot-start-marker
- boot-end-marker
- !
- !
- no aaa new-model
- memory-size iomem 5
- !
- !
- ip cef
- no ip domain lookup
- !
- interface Loopback0
- ip address 3.3.3.3 255.255.255.0
- !
- interface Serial0/0
- ip address 13.1.1.3 255.255.255.0
- serial restart-delay 0
- !
- interface Serial0/1
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/2
- ip address 23.1.1.3 255.255.255.0
- serial restart-delay 0
- !
- interface Serial0/3
- no ip address
- shutdown
- serial restart-delay 0
- !
- router rip
- version 2
- passive-interface Loopback0
- network 3.0.0.0
- network 13.0.0.0
- network 23.0.0.0
- no auto-summary
- !
- ip http server
- no ip http secure-server
- !
- control-plane
- !
- line con 0
- exec-timeout 0 0
- logging synchronous
- line aux 0
- line vty 0 4
- !
- !
- end
R3的配置:
- !
- version 12.4
- service timestamps debug datetime msec
- service timestamps log datetime msec
- no service password-encryption
- !
- hostname R4
- !
- boot-start-marker
- boot-end-marker
- !
- !
- no aaa new-model
- memory-size iomem 5
- !
- !
- ip cef
- no ip domain lookup
- !
- interface Loopback0
- ip address 4.4.4.4 255.255.255.0
- !
- interface Serial0/0
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/1
- ip address 14.1.1.4 255.255.255.0
- serial restart-delay 0
- !
- interface Serial0/2
- no ip address
- shutdown
- serial restart-delay 0
- !
- interface Serial0/3
- ip address 24.1.1.4 255.255.255.0
- serial restart-delay 0
- !
- router ospf 110
- router-id 4.4.4.4
- log-adjacency-changes
- passive-interface Loopback0
- network 4.4.4.0 0.0.0.255 area 0
- network 14.1.1.0 0.0.0.255 area 0
- network 24.1.1.0 0.0.0.255 area 0
- !
- ip http server
- no ip http secure-server
- !
- control-plane
- !
- line con 0
- exec-timeout 0 0
- logging synchronous
- line aux 0
- line vty 0 4
- !
- !
- end
重分布都是在ASBR上面配置的,图中将rip与ospf互相进行重分布,先解决metric的问题,在
rip 进程下面指定metric(我设置为1hop)
“
”
而ospf重分布进来的路由有初始的metric(cost=20&& external type 2)
“
”
ospf注意添加subnets参数,不然只会将主类路由引入。
如果只有r0一点进行重分布的话。路由表应该是:
“
- R1#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
- C 1.1.1.0 is directly connected, Loopback0
- 3.0.0.0/24 is subnetted, 1 subnets
- R 3.3.3.0 [120/1] via 13.1.1.3, 00:00:26, Serial0/0
- 4.0.0.0/32 is subnetted, 1 subnets
- O 4.4.4.4 [110/65] via 14.1.1.4, 00:00:40, Serial0/1
- 13.0.0.0/24 is subnetted, 1 subnets
- C 13.1.1.0 is directly connected, Serial0/0
- 14.0.0.0/24 is subnetted, 1 subnets
- C 14.1.1.0 is directly connected, Serial0/1
”
“
- 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
- R 1.1.1.0 [120/1] via 13.1.1.1, 00:00:04, Serial0/0
- 3.0.0.0/24 is subnetted, 1 subnets
- C 3.3.3.0 is directly connected, Loopback0
- 4.0.0.0/32 is subnetted, 1 subnets
- R 4.4.4.4 [120/1] via 13.1.1.1, 00:00:04, Serial0/0
- 13.0.0.0/24 is subnetted, 1 subnets
- C 13.1.1.0 is directly connected, Serial0/0
- 14.0.0.0/24 is subnetted, 1 subnets
- R 14.1.1.0 [120/1] via 13.1.1.1, 00:00:04, Serial0/0
”
“
- R4#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/20] via 14.1.1.1, 00:03:05, Serial0/1
- 3.0.0.0/24 is subnetted, 1 subnets
- O E2 3.3.3.0 [110/20] via 14.1.1.1, 00:03:05, Serial0/1
- 4.0.0.0/24 is subnetted, 1 subnets
- C 4.4.4.0 is directly connected, Loopback0
- 13.0.0.0/24 is subnetted, 1 subnets
- O E2 13.1.1.0 [110/20] via 14.1.1.1, 00:03:05, Serial0/1
- 14.0.0.0/24 is subnetted, 1 subnets
- C 14.1.1.0 is directly connected, Serial0/1
”
在r2上面的路由表可以看出从ospf重分布进来的4.4.4.4/32与14.1.1.0/24网段,至于为什么是4.4.4.4而不是4.4.4.0/24网段?这是ospf loopback接口的特性了(为什么可以做rid了--stub host)
“
”
而从r3上面重分布更明显可以看出,as外部路由的标识---第2外部路由(E2)
“
”
单点双向的重分布已经做完了,现在在看双点双向的重分布,这里有一个路由学习快慢的问题,这里不止牵扯到metric的问题,还有distance的问题了,在图中r0与r1都进行重分布,以r2的loopback 接口(3.3.3.3为例)
r0与r1都学习到r2 rip的路由(R 3.3.3.0/24 ),当r0进行重分布时,路由到达r3时为(O E2 3.3.3.0/24 ),r3在将该路由转发至r1,这时r1上既有rip的路由(R 3.3.3.0/24 ),也有(O E2 3.3.3.0/24 ),根据distance越小越可信(rip:120<ospf:110),r1只有一条路由(O E2 3.3.3.0/24 ),当r3访问3.3.3.0/24网段时,他该如何走?(至于是r0还是r1谁先重分布是个不定的因素,这要看路由更新的快慢了,可能在r0上面也有可能在r1上面)
解决这个问题,就是修改distance,当然不能将ospf路由都改成比rip大的,那就没有ospf路由条目了,只能将从rip重分布进来的路由的distance修改下就可以了(注:distance小的方面不会出现这样的问题,因为重分布进去的本来就是小变大,而原来转发路由distance小)
既可以在ospf进程下面做(将重分布进来的路由distance改超过原来的管理距离),也可以在rip进程下面做(将要重分布过去的路由distance改小于原来的管理距离),那么2个ASBR都会正确的学习到rip路由了。
这里我在ospf 进程下面修改
首先要确定那些路由,这里可以使用acl与ip prefix-list来抓路由,我这里用acl来抓这2条rip重分布进来的路由
“
”
分别在r0与r1上面配置
“r0上面:
distance 121 2.2.2.2 0.0.0.0 1
”
"r1上面
distance 121 1.1.1.1 0.0.0.0 1
"
当然抓路由也不是必须的,如果不加acl或者ip frefix-list,就是从adj那里学习来的所以路由的distance都变成121,而添加acl或者ip prefix-list,则为选中的路由更改distance。
浅说下ip prefix-list(前缀列表),与acl相似,最基础的,供其他调用,不同点是acl既可以是路由也可以是数据包,而ip prefix-list主要是路由,而且对netmask限制很好。比如
“
ip prefix-list 2 seq 5 permit 23.1.1.0/24
”
这条是选择permit“23.1.1.0/24”网段的,/25就不会选择,而acl就办不到这点。
现在在来看看r0与r1这两个ASBR上面的路由表,如果没有修改distance,一方上面应该没有rip的路由。
- R1#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
- C 1.1.1.0 is directly connected, Loopback0
- 2.0.0.0/32 is subnetted, 1 subnets
- O 2.2.2.2 [110/129] via 14.1.1.4, 00:00:28, Serial0/1
- 3.0.0.0/24 is subnetted, 1 subnets
- R 3.3.3.0 [120/1] via 13.1.1.3, 00:00:18, Serial0/0
- 4.0.0.0/32 is subnetted, 1 subnets
- O 4.4.4.4 [110/65] via 14.1.1.4, 00:00:28, Serial0/1
- 23.0.0.0/24 is subnetted, 1 subnets
- R 23.1.1.0 [120/1] via 13.1.1.3, 00:00:18, Serial0/0
- 24.0.0.0/24 is subnetted, 1 subnets
- O 24.1.1.0 [110/128] via 14.1.1.4, 00:00:28, Serial0/1
- 13.0.0.0/24 is subnetted, 1 subnets
- C 13.1.1.0 is directly connected, Serial0/0
- 14.0.0.0/24 is subnetted, 1 subnets
- C 14.1.1.0 is directly connected, Serial0/1
- R2#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
- R 1.1.1.0 [120/2] via 23.1.1.3, 00:00:21, Serial0/2
- 2.0.0.0/24 is subnetted, 1 subnets
- C 2.2.2.0 is directly connected, Loopback0
- 3.0.0.0/24 is subnetted, 1 subnets
- R 3.3.3.0 [120/1] via 23.1.1.3, 00:00:21, Serial0/2
- 4.0.0.0/32 is subnetted, 1 subnets
- O 4.4.4.4 [110/65] via 24.1.1.4, 00:01:35, Serial0/3
- 23.0.0.0/24 is subnetted, 1 subnets
- C 23.1.1.0 is directly connected, Serial0/2
- 24.0.0.0/24 is subnetted, 1 subnets
- C 24.1.1.0 is directly connected, Serial0/3
- 13.0.0.0/24 is subnetted, 1 subnets
- R 13.1.1.0 [120/1] via 23.1.1.3, 00:00:22, Serial0/2
- 14.0.0.0/24 is subnetted, 1 subnets
- O 14.1.1.0 [110/128] via 24.1.1.4, 00:01:36, Serial0/3
在去看看r3的路由表,
- R4#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/20] via 14.1.1.1, 00:03:20, Serial0/1
- 2.0.0.0/32 is subnetted, 1 subnets
- O 2.2.2.2 [110/65] via 24.1.1.2, 00:03:20, Serial0/3
- 3.0.0.0/24 is subnetted, 1 subnets
- O E1 3.3.3.0 [110/164] via 24.1.1.2, 00:03:20, Serial0/3
- 4.0.0.0/24 is subnetted, 1 subnets
- C 4.4.4.0 is directly connected, Loopback0
- 23.0.0.0/24 is subnetted, 1 subnets
- O E1 23.1.1.0 [110/164] via 24.1.1.2, 00:03:20, Serial0/3
- 24.0.0.0/24 is subnetted, 1 subnets
- C 24.1.1.0 is directly connected, Serial0/3
- 13.0.0.0/24 is subnetted, 1 subnets
- O E1 13.1.1.0 [110/164] via 24.1.1.2, 00:03:21, Serial0/3
- 14.0.0.0/24 is subnetted, 1 subnets
- C 14.1.1.0 is directly connected, Serial0/1
为什么没有负载均衡了,第一:metric不一样,但是应该都会是ospf external type 2的路由并从14.1.1.1那里学习来的啊,而且cost为20啊,这个就是ospf 路由优先级的问题, ospf路由优先级 域内》域间》e1》e2,所以e1会优先出现在路由表里面,看下topology 表,
- R4#show ip ospf database
- OSPF Router with ID (4.4.4.4) (Process ID 110)
- Router Link States (Area 0)
- Link ID ADV Router Age Seq# Checksum Link count
- 1.1.1.1 1.1.1.1 734 0x80000003 0x007AEC 2
- 2.2.2.2 2.2.2.2 733 0x80000003 0x002C05 3
- 4.4.4.4 4.4.4.4 732 0x80000002 0x0069F1 5
- Type-5 AS External Link States
- Link ID ADV Router Age Seq# Checksum Tag
- 1.1.1.0 1.1.1.1 929 0x80000001 0x00A5F3 0
- 3.3.3.0 1.1.1.1 784 0x80000001 0x005D36 0
- 3.3.3.0 2.2.2.2 783 0x80000001 0x00DEE0 0
- 13.1.1.0 1.1.1.1 784 0x80000001 0x000984 0
- 13.1.1.0 2.2.2.2 783 0x80000001 0x008A2F 0
- 23.1.1.0 1.1.1.1 784 0x80000001 0x0086FC 0
- 23.1.1.0 2.2.2.2 783 0x80000001 0x0008A7 0
从r0与r1都学习到了3.3.3.0/24这条路由,因为优先级ospf第一外部路由更高,所以出现在路由表中
那为什么还会有1.1.1.1这条第2外部路由出现在路由表当中?
那是因为没有做策略---router-map
rip重分布进入ospf时候,先执行了route-map的策略:metric +100,metric-type type-1。而route-map在调用ip prefix-list的时候,并没有"1.1.1.0/24"这条路由,所以忽略掉这条路由,其实这里应该添加一条route-map
“route-map OSPF permit 20
match ip address 2
access-list 2 permit 1.1.1.0
”
再去r3上面看ospf database
“
- R4#show ip ospf database
- OSPF Router with ID (4.4.4.4) (Process ID 110)
- Router Link States (Area 0)
- Link ID ADV Router Age Seq# Checksum Link count
- 1.1.1.1 1.1.1.1 1659 0x80000003 0x007AEC 2
- 2.2.2.2 2.2.2.2 1659 0x80000003 0x002C05 3
- 4.4.4.4 4.4.4.4 1658 0x80000002 0x0069F1 5
- Type-5 AS External Link States
- Link ID ADV Router Age Seq# Checksum Tag
- 1.1.1.0 1.1.1.1 1855 0x80000001 0x00A5F3 0
- 1.1.1.0 2.2.2.2 92 0x80000001 0x00870E 0
- 3.3.3.0 1.1.1.1 1710 0x80000001 0x005D36 0
- 3.3.3.0 2.2.2.2 1709 0x80000001 0x00DEE0 0
- 13.1.1.0 1.1.1.1 1710 0x80000001 0x000984 0
- 13.1.1.0 2.2.2.2 1709 0x80000001 0x008A2F 0
- 23.1.1.0 1.1.1.1 1710 0x80000001 0x0086FC 0
- 23.1.1.0 2.2.2.2 1709 0x80000001 0x0008A7 0
”
负载均衡了吧
- R4#show ip route ospf
- 1.0.0.0/24 is subnetted, 1 subnets
- O E2 1.1.1.0 [110/20] via 24.1.1.2, 00:02:48, Serial0/3
- [110/20] via 14.1.1.1, 00:02:48, Serial0/1
完毕
本文出自 “朝花夕拾” 博客,转载请与作者联系!