分类: 系统运维
2010-05-19 16:18:44
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 |
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 |
R4#sh ip route
………………
Gateway of last resort is not set
C 192.168.2.0/24 is directly connected, Serial1/0 (只有直连链路,并没有学习到路由) |
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 |
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 |
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 |
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 ? |
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 映射到路由表中,也就是转存一下) |
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转存BGP的AS-PATH属性 ) |
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 |
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方向) |
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