Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3321024
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类: 系统运维

2010-05-19 16:18:44

 
一、拓扑图:
 
 
 
二、配置步骤及说明:
1
、配置好各路由器的IP地址,并且下面依次看一下协议的配置步骤:
R1(config-if)#router bgp 64512
R1(config-router)#net 130.130.1.0 mask 255.255.255.0
R1(config-router)#net 192.168.1.0
R1(config-router)#nei 192.168.1.2 remote 64513
 
R2(config-if)#router bgp 64513
R2(config-router)#net 192.168.1.0
R2(config-router)#nei 192.168.1.1 remote 64512
R2(config-router)#router ospf 1
R2(config-router)#net 172.16.1.0 0.0.0.255 area 0
 
R3(config-if)#router ospf 1
R3(config-router)#net 172.16.1.0 0.0.0.255 area 0
R3(config-router)#router bgp 64513
R3(config-router)#net 192.168.2.0
R3(config-router)#nei 192.168.2.2 remote 64514
 
R4(config-if)#router bgp 64514
R4(config-router)#net 192.168.2.0
R4(config-router)#nei 192.168.2.1 remote 64513
2、发现配置完之后,查看一下R2R3的邻居关系:
R2#sh ip bgp summary
………………
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.1.1     4 64512       9       9        3    0    0 00:05:40        2
 
R3#sh ip bgp summary
………………
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.2.2     4 64514       7       7        2    0    0 00:03:12        1
3、查看R4的路由表,由于R2R3之间是运行的是OSPF协议,并没有BGP的邻接关系。所以R2R1学习到的BGP路由130.130.1.0/24的网络无法转发给R3路由器,因此R4上根本没有学习到任何的路由:
R4#sh ip route
………………
Gateway of last resort is not set
C    192.168.2.0/24 is directly connected, Serial1/0  (只有直连链路,并没有学习到路由)
4、为了让两边都能学到完整的路由,我们在R2R3上对BGPOSPF互做重分发:
R2(config)#router bgp 64513
R2(config-router)#red ospf 1 match external internal (将OSPF内部和外部类型都重分发到BGP中)
R2(config-router)#router ospf 1
R2(config-router)#red bgp 64513 subnets   (将BGP AS 64513自治系统重分发到OSPF进程当中)
 
R3(config)#router bgp 64513
R3(config-router)#redistribute ospf 1 match external internal
R3(config-router)#router ospf 1
R3(config-router)#redistribute bgp 64513 subnets
5、现在两边的路由都能学到了。并且重分发时没指定类型,R3学习到的外部路由默认以O E2呈现。我们来看一下R3R4的路由表:
R3#sh ip route
………………
Gateway of last resort is not set
 172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, FastEthernet0/0
     130.130.0.0/24 is subnetted, 1 subnets
O E2    130.130.1.0 [110/1] via 172.16.1.1, 00:05:33, FastEthernet0/0
O E2 192.168.1.0/24 [110/1] via 172.16.1.1, 00:05:33, FastEthernet0/0
C    192.168.2.0/24 is directly connected, Serial1/1
 
R4#sh ip route
………………
Gateway of last resort is not set
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.2.1, 00:10:10
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/1] via 192.168.2.1, 00:10:10
B    192.168.1.0/24 [20/1] via 192.168.2.1, 00:10:10
C    192.168.2.0/24 is directly connected, Serial1/0
6、查看一下R3R4BGP数据库发现:
R3#sh ip bgp
BGP table version is 5, local router ID is 192.168.2.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete (原代码说明:?代表不完整)
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   172.16.1.1               1         32768 ?(发现没有AS-PATH)
*> 172.16.1.0/24    0.0.0.0                  0         32768 ?
*> 192.168.1.0      172.16.1.1               1         32768 ?
*  192.168.2.0      192.168.2.2              0       0 64514 i
*>                  0.0.0.0                  0         32768 i
 
R4#sh ip bgp
BGP table version is 5, local router ID is 192.168.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   192.168.2.1              1             0 64513 ?(R4只学到AS没有PATH
*> 172.16.1.0/24    192.168.2.1              0             0 64513 ?
*> 192.168.1.0      192.168.2.1              1             0 64513 ?
*  192.168.2.0      192.168.2.1              0             0 64513 i
*>                  0.0.0.0                  0         32768 i
7、从上图发现R3R4的拓扑数据库不完整,同时我们也应该反推出R1R2学习到路由的AS-PATH属性也不会是完整的:
R1#sh ip bgp
…………
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   0.0.0.0                  0         32768 i
*> 172.16.1.0/24    192.168.1.2              0             0 64513 ?
*  192.168.1.0      192.168.1.2              0             0 64513 i
*>                  0.0.0.0                  0         32768 i
*> 192.168.2.0      192.168.1.2              1             0 64513 ?
 
R2#sh ip bgp
………………
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   192.168.1.1              0             0 64512 i
*> 172.16.1.0/24    0.0.0.0                  0         32768 ?
*  192.168.1.0      192.168.1.1              0             0 64512 i
*>                  0.0.0.0                  0         32768 i
*> 192.168.2.0      172.16.1.2               1         32768 ?
8、由于R2R3路由器把BGP路由协议重分发到OSPF中,而OSPF不能够识别BGP的路由AS-PATH属性。传递中导致全网中看到AS-PATH属性都不完整。
9
、下面将转到正题上:利用路由标记解决BGP中重分发时AS-PATH属性不完整。因为路由标记是可以被所有路由协议识别。但怎样去实施呢?可以在R2上将BGPAS-PATH转存到路由标记中,然后在R3路由器上重分发时再把路由标记中存储的AS-PATH取出来还原到BGP的路由中。
A
:下面我们到R2上将BGPAS-PATH转存到路由标记中:
R2(config)#route-map set_tag per 10 (建立一个名为set_tag路由图)
R2(config-route-map)#set automatic-tag(设置自动计算标记值,针对的是AS-PATH属性值)
R2(config-route-map)#router bgp 64513
R2(config-router)#table-map set_tag (将刚才设置的set_tag 映射到路由表中,也就是转存一下)
B:再到R3重分发时提取路由标记:
R3(config)#route-map get_tag per 10(建立一个路由图名为get_tag
R3(config-route-map)#set as-path tag(从路由标记中提取AS-PATH属性还原到BGP路由数据库中)
R3(config-route-map)#router bgp 64513
R3(config-router)#red ospf 1 match external internal route-map get_tag(利用重分发匹配外部和内部路由ospf 路由指向route-map转存BGPAS-PATH属性 )
10、现在来看一下R3R4BGP数据库。
R3#sh ip bgp
………………
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   172.16.1.1               1         32768 64512 ? AS-PATH有了,但起源属性还是不完整
*> 172.16.1.0/24    0.0.0.0                  0         32768 ?
*> 192.168.1.0      172.16.1.1               1         32768 ?
*  192.168.2.0      192.168.2.2              0             0 64514 i
*>                  0.0.0.0                  0         32768 i
R4#sh ip bgp
………………
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   192.168.2.1              1             0 64513 64512 ? (都显示?号为不完整)
*> 172.16.1.0/24    192.168.2.1              0             0 64513 ?
*> 192.168.1.0      192.168.2.1              1             0 64513 ?
*  192.168.2.0      192.168.2.1              0             0 64513 i
*>                  0.0.0.0                  0         32768 i
11、在R3设置起源,让R4能学到完整的BGP数据库:
R3(config)#route-map set_origin per 10 (针对起源再建立一个名为set_origin的路由图)
R3(config-route-map)#set origin igp (设置起源属性为IGP
R3(config-route-map)#router bgp 64513
R3(config-router)#nei 192.168.2.2 route-map set_origin out(利用路由图调用起源属性,指定下游out方向)
12、现在来看一下R4BGP数据库,发现已经完整了:
R4#sh ip bgp
………………
   Network          Next Hop            Metric LocPrf Weight Path
*> 130.130.1.0/24   192.168.2.1              1             0 64513 64512 i
*> 172.16.1.0/24    192.168.2.1              0             0 64513 i
*> 192.168.1.0      192.168.2.1              1             0 64513 i
*  192.168.2.0      192.168.2.1              0             0 64513 i
*>                  0.0.0.0                  0         32768 i
 
 

本文出自 “超越技术成就价值” 博客,请务必保留此出处http://supercisco.blog.51cto.com/672109/273771

阅读(1858) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~