外部BGP的基础配置(下)

简介: 文章目录系列文章目录实验目的实验拓扑实验步骤

查看BGP邻居关系的命令如下:


上述命令可以获知本地RID和AS,以及邻居的AS,建立时间已及状态。

注意,状态一栏,如果是数字的话,代表已经完成BGP邻居的建立。

R1#show ip bgp neighbor 2.2.2.2
BGP neighbor is 2.2.2.2,  remote AS 2, external link
  BGP version 4, remote router ID 2.2.2.2
  BGP state = Established, up for 02:07:04
  Last read 00:00:04, last write 00:00:04, hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    Route refresh: advertised and received(old & new)
    Address family IPv4 Unicast: advertised and received
  Message statistics:
    InQ depth is 0
    OutQ depth is 0
                         Sent       Rcvd
    Opens:                  1          1
    Notifications:          0          0
    Updates:                0          0
    Keepalives:           130        130
    Route Refresh:          0          0
    Total:                131        131
  Default minimum time between advertisement runs is 30 seconds
 For address family: IPv4 Unicast
  BGP table version 1, neighbor version 1/0
 Output queue size : 0
  Index 1, Offset 0, Mask 0x2
  1 update-group member
                                 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
  Connections established 1; dropped 0
  Last reset never
  External BGP neighbor may be up to 2 hops away.
Connection state is ESTAB, I/O status: 1, unread input bytes: 0            
Connection is ECN Disabled, Mininum incoming TTL 0, Outgoing TTL 2
Local host: 1.1.1.1, Local port: 38606
Foreign host: 2.2.2.2, Foreign port: 179
Enqueued packets for retransmit: 0, input: 0  mis-ordered: 0 (0 bytes)
Event Timers (current time is 0x102A524):
Timer          Starts    Wakeups            Next
Retrans           132          2             0x0
TimeWait            0          0             0x0
AckHold           129         44             0x0
SendWnd             0          0             0x0
KeepAlive           0          0             0x0
GiveUp              0          0             0x0
PmtuAger            0          0             0x0
DeadWait            0          0             0x0
iss:  128684281  snduna:  128686797  sndnxt:  128686797     sndwnd:  16061
irs: 3715000363  rcvnxt: 3715002879  rcvwnd:      16061  delrcvwnd:    323
SRTT: 300 ms, RTTO: 303 ms, RTV: 3 ms, KRTT: 0 ms
minRTT: 20 ms, maxRTT: 300 ms, ACK hold: 200 ms
Flags: active open, nagle
IP Precedence value : 6
Datagrams (max data segment is 536 bytes):
Rcvd: 233 (out of order: 0), with data: 130, total data bytes: 2534
Sent: 183 (retransmit: 2, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 131, total data bytes: 2534
R1#
show ip bgp neighbor  //命令显示了关于邻居更加详细的信息。


能够对BGP邻居关系进行管理性关闭。

R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 shutdown
R1(config-router)#
*Mar  1 04:53:41.510: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down Admin. shutdown
R1(config-router)#exit

如果需要重新开启邻居,则配置如下命令:

R1(config)#router bgp 1
R1(config-router)#no neighbor 2.2.2.2 shutdown
R1(config-router)#
*Mar  1 04:58:07.570: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up
R1(config-router)#exit

可以采用两种方式将路由插入到BGP表中。

| 使用network命令

| 使用重分布

在R1上建立3个环回口,loopback 1,loopback 2 和 loopback 3,地址分别为 192.168.1.1/24,192.168.2.1/24,192.168.3.1/24。

将1.1/24使用network插入BGP表,直连接口使用重分布,并且使用route-map只允许发布2.1/24.

R1(config)#int loo1
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#int loo2
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#exit
R1(config)#int loo3
R1(config-if)#ip add 192.168.3.1 255.255.255.0
R1(config-if)#exit
R1(config)#router bgp 1
R1(config-router)#network 192.168.1.0 mask 255.255.255.0 
R1(config-router)#exit

注意,如果使用network命令,该命令的含义为宣告某个网络.该网络必须已经存在本地路由表中。

如果不如mask的话,宣告的网络必须为主类。

当存在主类网络,不管是否配置了auto-aummary,主类网络都加入BGP表中不存在主类网络,而有明细之网的话,配置auto-summary,将会把子网汇总成为主类在加了BGP表中。

如果加入mask的话,那么掩码长度必须严格匹配。

R1(config)#ip prefix-list BGP per 192.168.2.1/24  建立一条前缀列表,只允许192.168.2.1 路由
R1(config)#route-map bgp per 10
R1(config-route-map)#match ip add prefix-list BGP
R1(config-route-map)#exit
R1(config)#router bgp 1
R1(config-router)#redistribute connected route-map bgp
R1(config-router)#exit

查看R2的BGP表项,验证上面配置的命令。


R2#show ip bgp 
BGP table version is 10, 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 Weight Path
r  1.1.1.0/24       10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
r  10.10.12.0/24    10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
r  10.10.21.0/24    10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
*  192.168.1.0      10.10.12.1               0             0 1 i
*>                  1.1.1.1                  0             0 1 i
*  192.168.2.0      10.10.12.1               0             0 1 ?
*>                  1.1.1.1                  0             0 1 ?
*  192.168.3.0      10.10.12.1               0             0 1 ?
*>                  1.1.1.1                  0             0 1 ?

R2#

通过上面的输出,我们要注意BGP表的格式。

例如,192.168.1.0表项,之前存在符号*,代表可用,如果缺失,往往是下一跳不可达或者存在更优路由。>符号表明为最佳路由,并且将插入路由表中。

同时还给出了下一跳属性,MED值,本地优先级,权重,AS-PATH属性和源起属性。

可以发现,我们所要求的都已经完成。

对于show ip bgp 命令,存在以下重要的选项:

show ip bgp 0.0.0.0 0.0.0.0 查看默认路由

show ip bgp prefix{sbnet-mast}基于具体前缀进行查看

show ip bgp neighbor ip-address received-routes 查看从某个邻居收到的路由,显示结果为入站过滤之前

show ip bgp neighbor ip-address routes 查看从某个邻居收到的路由,显示结果为入站过滤之后

show ip bgp neighbor ip-address advertised-routes 查看通告给某个邻居的路由,显示结果为出站过滤之后

最后,在R1上为192.168.1.0/24和192.168.2.0/24进行汇总,通告给R2.。

R1(config)#router bgp 1
R1(config-router)#aggregate-address 192.168.0.0 255.255.252.0 summary-only

注意上述命令中关键字 summary-only,如果不加,则会使得除了汇总路由,明细路由都将会被通告给邻居。

在R2上查看汇总结果。


R2#show ip bgp
BGP table version is 17, 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 Weight Path
r  1.1.1.0/24       10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
r  10.10.12.0/24    10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
r  10.10.21.0/24    10.10.12.1               0             0 1 ?
r>                  1.1.1.1                  0             0 1 ?
*  192.168.0.0/22   10.10.12.1               0             0 1 i
*>                  1.1.1.1                  0             0 1 i
R2#
目录
相关文章
|
2月前
|
网络协议 网络虚拟化 数据中心
华为配置VXLAN构建虚拟网络实现相同网段互通示例(静态方式)
配置VXLAN构建虚拟网络实现相同网段互通示例(静态方式
|
8天前
|
负载均衡 网络协议 网络架构
|
10月前
|
网络协议
BGP的基础配置
BGP的基础配置
69 0
|
存储 网络协议 安全
BGP 路由反射:全互联内部 BGP (IBGP) 的替代方案
本文档为 Internet 团体指定了 Internet 标准跟踪协议,并请求讨论和改进建议。本协议的标准化状态和现状请参考当前版本的《互联网官方协议标准》(STD 1)。本备忘录的分发不受限制。
208 0
BGP 路由反射:全互联内部 BGP (IBGP) 的替代方案
|
负载均衡 网络协议 网络架构
外部BGP的基础配置(上)
文章目录 系列文章目录 实验目的 实验拓扑 实验步骤
94 0
外部BGP的基础配置(上)
|
网络架构 网络性能优化