BGP1

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 the following
conditions exists:
          --- An AS allows packets to transit through it to reach other autonomous systems(for example ,it si a service provider).
          ---   An AS has multiple connections to other autonomous systems.
          --Routing policy and route selection for traffic entering and leaving the AS must be manipulated.
        BGP is not always appropriate,You do not have to use BGP if you have one of the following conditions:
          ---Limited understanding of route filtering and BGP path-selection process.
          ---A single connection to the Internet or another AS
          ---Lack of memory or processor power to handle constant updates on BGP 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,the Internet)

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 multiple networks)
      ---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 specific term that is used for BGP speakers that have established a neighbor relationship
  • Any two routers that have formed a TCP connection to exchange BGP routing Information are called BGP peers or BGP neighbors.
External BGP
  • When BGP is running between neighbors that belong to different autonomous 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 is called 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 not recommended.
  • 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 propagated to
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 bgp summary 
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           4             1       14       14         1     0                                     0 00:09:22           0

R2#show ip bgp neighbors
BGP neighbor is 24.1.1.4,   remote AS 4, external link
  BGP version 4, remote router ID 4.4.4.4
  BGP state = Established, up for 00: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 not multisession capable (disabled)
  Neighbor capabilities:
    Route refresh: advertised and received(new)
    Four-octets ASN Capability: advertised and received
    Address family IPv4 Unicast: advertised and received
    Enhanced Refresh Capability: advertised and received
    Multisession Capability: 
    Stateful switchover support enabled: NO for session 1
  Message statistics:
    InQ depth is 0
    OutQ depth is 0
     
                          Sent       Rcvd
    Opens:                   1           1
    Notifications:         0           0
    Updates:               1           1
    Keepalives:           3           3
    Route Refresh:       0           0
    Total:                     5           5
  Default minimum time between advertisement runs is 30 seconds

  For address family: IPv4 Unicast
  Session: 24.1.1.4
  BGP table version 1, neighbor version 1/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 is disabled
                                  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           0

  Address tracking is enabled, the RIB does have a route to 24.1.1.4
  Connections established 1; dropped 0
  Last reset never
  Transport(tcp) path-mtu-discovery is enabled
  Graceful-Restart is disabled
Connection state is ESTAB, I/O status: 1, unread input bytes: 0            
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 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           0             0x0
TimeWait             0           0             0x0
AckHold             4           2             0x0
SendWnd             0           0             0x0
KeepAlive           0           0             0x0
GiveUp               0           0             0x0
PmtuAger             0           0             0x0
DeadWait             0           0             0x0
Linger               0           0             0x0
ProcessQ             0           0             0x0

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

sndwnd:   16247   scale:       0   maxrcvwnd:   16384
rcvwnd:   16247   scale:       0   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, fast processed: 0, slow path: 0
  fast lock acquisition failures: 0, slow path: 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-source Loopback0
  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-source Loopback0


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

      Network           Next Hop             Metric LocPrf Weight Path
  *>   4.4.4.0/24       0.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, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

      Network           Next Hop             Metric LocPrf 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, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

      Network           Next Hop             Metric LocPrf 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.3 next-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, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

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

BGP Synchronization
Synchronization rule:Do not use or advertise to an external neighbor a route learned by IBGP until a 
matching route has been learned from an IGP
  •       Ensures consistency of information throughout the AS
  •       Safe to have it off only if all routers in the transit path in the AS are running full-mes IBGP:off by default in Cisco software release 12.2(8)
Router(config-router)#
no synchronization
  •       Disables BGP synchronization so that a router will advertise routes in IGP without learning them in an IGP
Router (config-router)#
synchronization
  • Enables BGP synchronization so that a router will not advertise routers 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-group peer-group-name
  • This command defines a template with parameters set for a group of neighbors instead of individually.
  • This command is useful when many neighbors have the same outbound 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-source Loopback0
  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-source Loopback0
  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-source Loopback0
!

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-source Loopback0
!


 
### BGP协议回环接口实验配置 #### 实验环境准备 为了完成BGP协议的回环接口实验配置,需搭建一个网络拓扑结构。假设存在三台路由器(R1、R2 和 R3),其中 R1 和 R2 是 eBGP 对等体,R2 和 R3 是 iBGP 对等体。 #### 配置步骤说明 ##### 1. **启用并配置 OSPF** 由于 iBGP 使用回环接口建立邻居关系,因此需要先通过 IGP 提供回环接口的路由信息。这里选择 OSPF 来实现这一功能[^2]。 ```shell Router(config)# router ospf 1 Router(config-router)# network <network> <wildcard-mask> area 0 ``` 例如,在每台设备上分别配置如下: - **R1**: `network 192.168.1.0 0.0.0.255 area 0` - **R2**: `network 192.168.1.0 0.0.0.255 area 0`, `network 192.168.2.0 0.0.0.255 area 0` - **R3**: `network 192.168.2.0 0.0.0.255 area 0` 确保所有设备能够互相通信,并能访问彼此的回环接口地址。 ##### 2. **创建回环接口** 在各路由器上创建回环接口,并分配唯一的 IP 地址。 ```shell Router(config)# interface loopback 0 Router(config-if)# ip address <loopback-ip> 255.255.255.255 ``` 例如: - **R1**: `ip address 1.1.1.1 255.255.255.255` - **R2**: `ip address 2.2.2.2 255.255.255.255` - **R3**: `ip address 3.3.3.3 255.255.255.255` 这些回环接口将用于后续的 BGP 邻居关系建立。 ##### 3. **配置 eBGP 邻居关系** 在 R1 上配置与 R2 的 eBGP 关系,使用物理接口作为连接方式。 ```shell Router(config)# router bgp <AS-number> Router(config-router)# neighbor <neighbor-ip> remote-as <remote-AS-number> ``` 例如: - **R1**: ```shell Router(config)# router bgp 100 Router(config-router)# neighbor 192.168.1.2 remote-as 200 ``` 验证 eBGP 是否成功建立: ```shell Router# show ip bgp neighbors ``` ##### 4. **配置 iBGP 邻居关系** 在 R2 和 R3 上配置基于回环接口的 iBGP 邻居关系。注意,iBGP 不会向其他 iBGP 对等体传播学到的路由,因此可能需要引入外部路由或使用反射器技术来解决水平分割问题。 ```shell Router(config)# router bgp <AS-number> Router(config-router)# neighbor <loopback-ip> remote-as <local-AS-number> Router(config-router)# update-source loopback 0 ``` 例如: - **R2**: ```shell Router(config)# router bgp 200 Router(config-router)# neighbor 3.3.3.3 remote-as 200 Router(config-router)# update-source loopback 0 ``` - **R3**: ```shell Router(config)# router bgp 200 Router(config-router)# neighbor 2.2.2.2 remote-as 200 Router(config-router)# update-source loopback 0 ``` 如果发现邻居无法正常建立,则可能是回环接口不可达引起的[^4]。可以通过静态路由或其他方法确保回环接口可达性。 ##### 5. **验证 BGP 邻居状态** 检查 BGP 邻居是否已成功建立。 ```shell Router# show ip bgp summary ``` 预期输出应显示邻居处于“Established”状态。 --- ### 注意事项 - 如果回环接口未被正确通告至整个网络,可能导致 iBGP 邻居关系无法建立。可以尝试手动添加静态路由以解决问题。 - 在实际环境中,建议使用 BGP 路由反射器或联盟机制优化大规模 iBGP 网络的设计。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tjjingpan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值