BGP1

来源:互联网 发布:曾荫权对抗中央 知乎 编辑:程序博客网 时间:2024/06/01 10:34
BGP Autonomous Systems
AS号:公有 0-64511
        :私有:64512-65535

AS号查询
http://www.cidr-report.org/as6447/autnums.html

BGP Path-Vector Routing
AS相当于一个大路由器

AS-by-AS
 
BGP Characteristics
BGP is most appropriate when at least one of thefollowing
conditions exists:
     --- An AS allows packets to transit through it to reach otherautonomous systems(for example ,it si a service provider).
     ---  An AS has multiple connections to otherautonomous systems.
     --Routing policy and route selection for traffic entering andleaving the AS must be manipulated.
    BGPis not always appropriate,You do not have to use BGP if you haveone of the following conditions:
     ---Limited understanding of route filtering and BGP path-selectionprocess.
     ---A single connection to the Internet or another AS
     ---Lack of memory or processor power to handle constant updates onBGP routers.
 
电信---网通
1、管理
2、OSPF 10000条,ISIS,20000条,internet 10几万条
3、BGP策略路由
4、 ---扩展应用,ipv4、ipv6、vpnv4、MPLS
 
BGP Characteristic(Count.)
BGP is a path-vector protocol with the follow
enhancements over distance vector protocols:
     ---Reliable updates:runs on top of TCP (port 179)
     ---Incremental,triggered updates only
     ---Periodic keep-alive messages to verify TCP connectivity
     ---Rich metrics (called path vectors or attributes)
     ---Designed to scale to huge inter-networks(for example,theInternet)

BGP Databases(三张表)
Neighbor table
     --List of BGP neighbors
BGP table(forwarding database)
     ---List of all networks learned from each neighbor
     ---Can contain multiple paths to destination networks
     ---Contains BGP attributes for each path
IP routing table
     ---List of best paths to destination networks
不做负载均衡

AD
IBGP   200
EBGP 20

BGP Message Types
BGP defines the following message types:
Open
     ---Includes hold time and BGP router ID
Keepalive
Update
     ---Information for one path only(could be to multiplenetworks)
     ---Includes path attributes and networks
Notification
     ---When error is detected
     ---BGP connection closed after message is sent

_______________________________________________________________________
Explaining EBGP and IBGP

Peers = Neighbors
  • A "BGP peer," also known as a "BGP neighbor," is a specificterm that is used for BGP speakers that have established a neighborrelationship
  • Any two routers that have formed a TCP connection to exchangeBGP routing Information are called BGP peers or BGP neighbors.
External BGP
  • When BGP is running between neighbors that belong to differentautonomous systems,it is called EBGP.
  • EBGP neighbors,by default,need to be directly connected.
Internal BGP
  • When BGP is running between neighbors within the save AS,it iscalled IBGP
  • The neighbors do not have to be directly connected.
IBGP in a Transit AS (ISP)

BGP1

  • Redistributing BGP into an IGP (OSPF in this example) is notrecommended.
  • Instead,run IBGP on all routers.

解决路由黑洞
1、物理线路FULL MESH
2、BGP邻居的FULL MESH
3、将BGP重分布到IGP(LAB)
4、MPLS( 最好的解决方案)

IBGP In a NonTransit AS 
EBGP水平分割
不接收含有本AS号的BGP路由。
IBGP
By default,routers learned via IBGP are never propagatedto
other IBGP peers,so they need full-mesh IBGP
有条件的打破 IGBP水平分割。

BGP1
IBGP
network hello邻居
              通告路由


EBGP
Neighbor
network

R4上的配置
router bgp 4
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 neighbor 24.1.1.2 remote-as 1

R2上的配置
router bgp 1
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor 24.1.1.4 remote-as 4


R4#show ip bgpsummary 
BGP router identifier 4.4.4.4, local AS number 4
BGP table version is 1, main routing table version 1

Neighbor       V         AS MsgRcvd MsgSent   TblVer InQ OutQ Up/Down State/PfxRcd
24.1.1.2                      14     14      1                                 0 00:09:22         0

R2#show ip bgp neighbors
BGP neighbor is 24.1.1.4,  remoteAS 4, external link
  BGP version 4, remote router ID4.4.4.4
  BGP state = Established, up for00:02:00
  Last read 00:00:03, last write 00:00:00,hold time is 180, keepalive interval is 60 seconds
  Neighbor sessions:
    1 active, is notmultisession capable (disabled)
  Neighbor capabilities:
    Route refresh:advertised and received(new)
    Four-octets ASNCapability: advertised and received
    Address family IPv4Unicast: advertised and received
    Enhanced RefreshCapability: advertised and received
    MultisessionCapability: 
    Stateful switchoversupport enabled: NO for session 1
  Message statistics:
    InQ depth is 0
    OutQ depth is 0
    
                     Sent      Rcvd
    Opens:                      1
    Notifications:      0         0
    Updates:            1         1
    Keepalives:         3        3
    Route Refresh:            0
    Total:                 5         5
  Default minimum time between advertisementruns is 30 seconds

 For address family: IPv4 Unicast
  Session: 24.1.1.4
  BGP table version 1, neighbor version1/0
  Output queue size : 0
  Index 1, Advertise bit 0
  1 update-group member
  Slow-peer detection is disabled
  Slow-peer split-update-group dynamic isdisabled
                            Sent      Rcvd
  Prefix activity:             ----      ----
    Prefixes Current:            0         0
    Prefixes Total:              0        0
    Implicit Withdraw:           0         0
    Explicit Withdraw:           0         0
    Used as bestpath:           n/a        0
    Used as multipath:          n/a        0

                              Outbound   Inbound
  Local Policy Denied Prefixes:   --------   -------
    Total:                          0         0
  Number of NLRIs in the update sent: max 0,min 0
  Last detected as dynamic slow peer:never
  Dynamic slow peer recovered: never
  Refresh Epoch: 1
  Last Sent Refresh Start-of-rib: never
  Last Sent Refresh End-of-rib: never
  Last Received Refresh Start-of-rib:never
  Last Received Refresh End-of-rib:never
                                 Sent      Rcvd
       Refresh activity:            ----      ----
         Refresh Start-of-RIB        0        0
         Refresh End-of-RIB                 0

  Address tracking is enabled, the RIB doeshave a route to 24.1.1.4
  Connections established 1; dropped 0
  Last reset never
  Transport(tcp) path-mtu-discovery isenabled
  Graceful-Restart is disabled
Connection state is ESTAB, I/O status: 1, unread input bytes:0           
Connection is ECN Disabled, Mininum incoming TTL 0, OutgoingTTL 1
Local host: 24.1.1.2, Local port:179
Foreign host: 24.1.1.4, Foreign port:48615
Connection tableid (VRF): 0
Maximum output segment queue size: 50

Enqueued packets for retransmit: 0, input: 0 mis-ordered: 0 (0 bytes)

Event Timers (current time is 0x31CD9):
Timer         Starts   Wakeups          Next
Retrans           5                   0x0
TimeWait          0                   0x0
AckHold           4                   0x0
SendWnd           0                   0x0
KeepAlive                0           0x0
GiveUp            0        0           0x0
PmtuAger          0                   0x0
DeadWait          0                   0x0
Linger            0        0           0x0
ProcessQ          0                   0x0

iss: 3917151808  snduna: 3917151946 sndnxt: 3917151946
irs: 1610121879  rcvnxt: 1610122017

sndwnd:  16247  scale:     maxrcvwnd:  16384
rcvwnd:  16247  scale:     delrcvwnd:   137

SRTT: 487 ms, RTTO: 3168 ms, RTV: 2681 ms, KRTT: 0 ms
minRTT: 7 ms, maxRTT: 1000 ms, ACK hold: 200 ms
Status Flags: passive open, gen tcbs
Option Flags: nagle, path mtu capable
IP Precedence value : 6

Datagrams (max data segment is 1460 bytes):
Rcvd: 11 (out of order: 0), with data: 5, total data bytes:137
Sent: 10 (retransmit: 0, fastretransmit: 0, partialack: 0,Second Congestion: 0), with data: 5, total data bytes: 137

 Packets received in fast path: 0, fastprocessed: 0, slow path: 0
 fast lock acquisition failures: 0, slowpath: 0
TCP Semaphore     0xF49FCF8C FREE 

R2#show tcp brief 
TCB      Local Address             Foreign Address          (state)
F1559798  24.1.1.2.179            24.1.1.4.48615            ESTAB
F4BFA5F8  2.2.2.2.17210            3.3.3.3.179              ESTAB


IBGP建议用环回接口建邻居。

更新源
NEI 24.1.1.2  NEI 24.1.1.4
US:24.1.1.4  US 24.1.1.2

NEI 3.3.3.3 NEI 2.2.2.2 
US 12.1.1.2 US13.1.1.3

R2上的配置
router ospf 110
 router-id 2.2.2.2
 network 2.2.2.0 0.0.0.255 area 0
 network 12.1.1.0 0.0.0.255 area 0

router bgp 1
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor 3.3.3.3 remote-as 1
 neighbor 3.3.3.3 update-sourceLoopback0
 neighbor 24.1.1.4 remote-as 4

R1上的配置
router ospf 1
 router-id 1.1.1.1
 network 12.1.1.0 0.0.0.255 area 0
 network 13.1.1.0 0.0.0.255 area 0

R3上的配置
router ospf 110
 router-id 3.3.3.3
 network 3.3.3.0 0.0.0.255 area 0
 network 13.1.1.0 0.0.0.255 area 0

router bgp 1
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 1
 neighbor 2.2.2.2 update-sourceLoopback0


Example ebgp-multihop command
BGP1


A路由器配置
router bgp 65102
neighbor 1.1.1.1 remote-as 65101
neighbor 1.1.1.1 update-source Loopback 0
neighbor 1.1.1.1 ebgp-multihop 2
ip route 1.1.1.1 255.255.255.255 192.168.1.18
ip route 1.1.1.1 255.255.255.255 192.168.1.34
B路由器配置
router bgp 65101
neighbor 2.2.2.2 remote-as 65102
neighbor 2.2.2.2 update-source Loopback 0
neighbor 2.2.2.2 ebgp-multihop 2
ip route 2.2.2.2 255.255.255.255 192.168.1.17
ip route 2.2.2.2 255.255.255.255 192.168.1.33

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, m multipath, bbackup-path, f RT-Filter, 
            x best-external, a additional-path, cRIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network         Next Hop          MetricLocPrf Weight Path
 *>  4.4.4.0/24      0.0.0.0                     32768 i
*:为可用的,>:最优的路由


R2#show ip bgp
BGP table version is 2, 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, m multipath, bbackup-path, f RT-Filter, 
            x best-external, a additional-path, cRIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network         Next Hop          MetricLocPrf Weight Path
 *>  4.4.4.0/24      24.1.1.4              0           0 4 i

R3#show ip bgp
BGP table version is 1, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, >best, i - internal, 
            r RIB-failure, S Stale, m multipath, bbackup-path, f RT-Filter, 
            x best-external, a additional-path, cRIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network         Next Hop          MetricLocPrf Weight Path
 * i 4.4.4.0/24      24.1.1.4              0    100     0 4 i

没有>:(不优的路由)
1、不会进路由表。
2、不会给其他BGP邻居传。

BGP路由优的条件:
1、同步(从IGP学习到/no syn)
2、下一跳

R3(config)#router bgp 1
R3(config-router)#no sy
R3(config-router)#no synchronization 

R2(config-router)#neighbor 3.3.3.3next-hop-self 

R3#show ip bgp  
BGP table version is 2, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, >best, i - internal, 
            r RIB-failure, S Stale, m multipath, bbackup-path, f RT-Filter, 
            x best-external, a additional-path, cRIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network         Next Hop          MetricLocPrf Weight Path
 *>i 4.4.4.0/24      2.2.2.2               0   100     0 4 i

BGPSynchronization
Synchronization rule:Do not use or advertise to an externalneighbor a route learned by IBGP until a 
matching route has been learned from an IGP
  •      Ensures consistency of information throughout the AS
  •       Safeto have it off only if all routers in the transit path in the ASare running full-mes IBGP:off by default in Cisco software release12.2(8)
Router(config-router)#
no synchronization
  •      Disables BGP synchronization so that a router will advertise routesin IGP without learning them in an IGP
Router (config-router)#
synchronization
  • Enables BGP synchronization so that a router will not advertiserouters in BGP until it learns them in an IGP

Using a peer group
Router(config-router)#
neighbor peer-group-name peer-group
  • This command creates a peer group.
Router(config-router)#
neighbor ip-address peer-grouppeer-group-name
  • This command defines a template with parameters set for a groupof neighbors instead of individually.
  • This command is useful when many neighbors have the sameoutbound policies.
  • Members can have a different inbound policy.
  • Updates are generated once per peer group.
  • Configuration is simplified.

R1#show run | b r b
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor aaa peer-group
 neighbor aaa remote-as 1
 neighbor aaa update-source Loopback0
 neighbor 2.2.2.2 peer-group aaa
 neighbor 3.3.3.3 peer-group aaa

R4#show run | b r b
router bgp 4
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 network 4.4.4.0 mask 255.255.255.0
 neighbor 24.1.1.2 remote-as 1

R2#show run | b r b
router bgp 1
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 neighbor aaa peer-group
 neighbor aaa remote-as 1
 neighbor aaa update-source Loopback0
 neighbor aaa next-hop-self
 neighbor 1.1.1.1 peer-group aaa
 neighbor 3.3.3.3 remote-as 1
 neighbor 3.3.3.3 update-sourceLoopback0
 neighbor 3.3.3.3 next-hop-self
 neighbor 24.1.1.4 remote-as 4

R1#show run | b r b
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor aaa peer-group
 neighbor aaa remote-as 1
 neighbor aaa update-source Loopback0
 neighbor 2.2.2.2 peer-group aaa
 neighbor 3.3.3.3 peer-group aaa

R3#show run | b r b
router bgp 1
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 neighbor aaa peer-group
 neighbor aaa remote-as 1
 neighbor aaa update-source Loopback0
 neighbor aaa next-hop-self
 neighbor 1.1.1.1 peer-group aaa
 neighbor 2.2.2.2 remote-as 1
 neighbor 2.2.2.2 update-sourceLoopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 5.5.5.5 remote-as 5
 neighbor 5.5.5.5 ebgp-multihop 2
 neighbor 5.5.5.5 update-sourceLoopback0
!

R5#show run | b r b
router bgp 5
 bgp log-neighbor-changes
 network 5.5.5.0 mask 255.255.255.0
 neighbor 3.3.3.3 remote-as 1
 neighbor 3.3.3.3 ebgp-multihop 2
 neighbor 3.3.3.3 update-sourceLoopback0
!


 
原创粉丝点击