BGP3

来源:互联网 发布:linux free m 详解 编辑:程序博客网 时间:2024/06/06 20:01
 1、传播范围
2、默认值
3、值大好还是小好
BGP3
8、Prefer the path through the closest iGPneighbor.
11,65,环回口

R3#show ip bgp 2.2.2.0/24
BGP routing table entry for 2.2.2.0/24, version 3
Paths: (2 available, best #2, table default)
  Not advertised to any peer
  2
    1.1.1.1 (metric 65) from1.1.1.1 (1.1.1.1)
     Origin IGP, metric 0, localpref 100, valid, internal
  2
    4.4.4.4 (metric 11) from4.4.4.4 (4.4.4.4)
     Origin IGP, metric 0, localpref 100, valid, internal, best

R3#show ip route
Codes: L - local, 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 NSSAexternal type 2
      E1 - OSPF external type 1, E2 - OSPF externaltype 2
      i - IS-IS, su - IS-IS summary, L1 - IS-ISlevel-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, +- replicated route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/65] via 13.1.1.1, 00:33:44,Serial2/0
     2.0.0.0/24 is subnetted, 1 subnets
B       2.2.2.0 [200/0] via 4.4.4.4,00:06:14
     3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       3.3.3.0/24 is directly connected, Loopback0
L       3.3.3.3/32 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/11] via 34.1.1.4, 00:31:22,Ethernet0/1
     13.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       13.1.1.0/24 is directly connected,Serial2/0
L       13.1.1.3/32 is directly connected,Serial2/0
     34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       34.1.1.0/24 is directly connected,Ethernet0/1
L       34.1.1.3/32 is directly connected,Ethernet0/1

R2再增加一条路由,9.9.9.0/24,   R3 访问2.2.20/24 和9.9.9.9  从R1 上走, 默认从R4上走,人为控制选路

BGP3

weight值
默认weight为32768
R2#show ip bgp
BGP table version is 1, local router ID is 2.2.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 WeightPath
*  2.2.2.0/24      0.0.0.0               0        32768i
*  9.9.9.0/24      0.0.0.0               0        32768i

R1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.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 WeightPath
*> 2.2.2.0/24      12.1.1.2                        0 2i
*> 9.9.9.0/24      12.1.1.2                        0 2i

R3(config-router)#neighbor1.1.1.1 weight 1 //默认in方向
R3#clear ip bgp  *soft 
BGP3
weight调为1 ,从R1上走

2.2.2.0/24从r1走,9.9.9.0/24从r4走
R3上的配置

ip prefix-list 2 seq 5 permit 2.2.2.0/24

route-map W permit 10
 match ip address prefix-list 2
 set weight 3

route-map W permit 20

router bgp 1
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 1
 neighbor 1.1.1.1 update-sourceLoopback0
 neighbor 1.1.1.1route-map W in
 neighbor 4.4.4.4 remote-as 1
 neighbor 4.4.4.4 update-sourceLoopback0
 no auto-summary
结果
BGP3

Weight Attribute(CiscoOnly)

Local PreferenceAttribute
Path with highest localpreference value are preferred:
  • Local preference is used to advertise to IBGP neighbors abouthow to leave their AS.
  • The local preference is sent to IBGP neighbors only (that is,within the AS only).
  • The local preference attribute is well-known anddiscretionary.
  • Default value is 100
默认路由从R4上走,通过设置R1的local preference attribute,使路由从r1上走

BGP3


R1(config-router)#bgp default local-preference 111
BGP3

BGP3


R3#show ip bgp 2.2.2.0/24
BGP routing table entry for 2.2.2.0/24, version 4
Paths: (2 available, best #1, table default)
  Not advertised to any peer
  2
    1.1.1.1 (metric 65) from1.1.1.1 (1.1.1.1)
     Origin IGP, metric 0, localpref 111,valid, internal, best
  2
    4.4.4.4 (metric 11) from4.4.4.4 (4.4.4.4)
     Origin IGP, metric 0, localpref 100, valid, internal
1、network ???
2、ebgp ???
3、IGBP ???
4、agg ??


做路由分担,2.2.2.0/24从r1上走,9.9.9.0/24从r4上走

R1 上配置

BGP3




BGP3


BGP3

BGP3


BGP3
BGP3
BGP3
R3访问2.2.2.0/24 网络通过r1,设置As path来实现
从出方向设置,R2发给R42.2.2..0/24path增加,

R2
 set as-path prepend 6 78 
neighbor 24.1.1.4 route-map AS out
当R2把这条路由发出去之前,已经有了 6 7 8 AS号

BGP3

IN方向

BGP3

BGP3
人为修改AS PATH弊端
容易造成EBGP环路。
prepend 自己的AS号

MEDAttribute
The path with the lowest MED(also called the metric) value are the most desirable
-MED is used t advertise toEBGP neighbors how to exit their AS to reach networks owned by thisAS.
The MED attribute is optionaland nontransitive.

通过设置MED属性,使R2去8.8.8.0/24,通过R4走。
R1上通过设置MED属性大于0,则可以使远端EBGP R2 去往8.8.8.0/24通过r4走
BGP3
设置之前

BGP3
设置之后
BGP3


R1#debug ip bgp updates 

最常用的这两个
local preference
MED

由于水平分割的问题,在IBGP中,R1发给R3的路由,R3,不会发给R4,如下图。
解决IBGP的水平分割:
1、路由反射器
2、联邦
 

BGP3

BGP3


BGP3

R1
router bgp 64512
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 bgp confederationidentifier 1
 neighbor 3.3.3.3remote-as 64512
 neighbor 3.3.3.3update-source Loopback0
 neighbor 3.3.3.3next-hop-self
 neighbor 12.1.1.2 remote-as 2
 no auto-summary
R3
!
router bgp 64512
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 bgp confederationidentifier 1
 bgp confederationpeers 64513 
 neighbor 1.1.1.1remote-as 64512
 neighbor 1.1.1.1 update-sourceLoopback0
 neighbor 4.4.4.4 remote-as 64513
 neighbor 4.4.4.4ebgp-multihop 255
 neighbor 4.4.4.4 update-sourceLoopback0
 no auto-summary
R4
router bgp 64513
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 bgp confederationidentifier 1
 bgp confederationpeers 64512 
 neighbor 3.3.3.3remote-as 64512
 neighbor 3.3.3.3ebgp-multihop 255
 neighbor 3.3.3.3 update-sourceLoopback0
 no auto-summary
R4#show ip route bgp
Codes: L - local, 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 NSSAexternal type 2
      E1 - OSPF external type 1, E2 - OSPF externaltype 2
      i - IS-IS, su - IS-IS summary, L1 - IS-ISlevel-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, +- replicated route

Gateway of last resort is not set

     2.0.0.0/24 is subnetted, 1 subnets
B       2.2.2.0 [200/0] via 1.1.1.1, 00:03:54


R4#show ip bgp 2.2.2.2/24
BGP routing table entry for 2.2.2.0/24, version 2
Paths: (1 available, best #1, table default)
  Not advertised to any peer
  (64512) 2
    1.1.1.1 (metric 75) from3.3.3.3 (3.3.3.3)
     Origin IGP, metric 0, localpref 100, valid, confed-external, best

R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
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 WeightPath
*> 2.2.2.0/24      1.1.1.1               0    100     0(64512) 2 i
_____________________________________________________________________________________
 社团属性:community
可选:路由器可能不识别此属性.(default)
neighbor x.x.x.x. send-community
传递;些属性只在nei的邻居有效
neighbor x.x.x.x send-community

R2
route-map COM permit 10
 set community no-advertise

router bgp 2
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 network 2.2.2.0 mask 255.255.255.0
 neighbor 12.1.1.1 remote-as 1
 neighbor 12.1.1.1 send-community
 neighbor 12.1.1.1route-map COM out
 neighbor 24.1.1.4 remote-as 1
 neighbor 24.1.1.4 route-map AS out
 no auto-summary

R1#show ip bgp 2.2.2.2/24
BGP routing table entry for 2.2.2.0/24, version 3
Paths: (1 available, best #1, table default, not advertised toany peer)
  Not advertised to any peer
  2
    12.1.1.2 from 12.1.1.2(2.2.2.2)
     Origin IGP, metric 0, localpref 100, valid, external, best
     Community: no-advertise
no-advertise  , 携带此属性的路由不会通知给任何给BGP邻居。
no-export:携带此属性的路由不会传出大AS
local-AS:携带此属性的路由不会传出小AS.