yyert 发表于 2017-12-6 12:50:57

BGP的邻居建立

# IGBP直连邻居建立
# neighbor 10.1.23.3 remote-as 234 的作用:
# 1、与10.1.23.3:179建立TCP连接;
# 2、源检测,只允许10.1.23.3建立localhost:179连接;
# 3、主动发起TCP连接;被动接收TCP连接;
IOU2(config-router)#neighbor 10.1.23.2 transport connection-mode ?
active   Actively establish the TCP session
passivePassively establish the TCP session

IOU2#sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.23.3 remote-as 234

IOU3#sh run | b r b
router bgp 234
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 10.1.23.2 remote-as 234

IOU2#sh ip bgp summ
BGP router identifier 2.2.2.2, local AS number 234
BGP table version is 1, main routing table version 1

Neighbor      V         AS MsgRcvd MsgSent   TblVerInQ OutQ Up/DownState/PfxRcd
10.1.23.3       4          234      18      18      1    0    0 00:13:20      0

# 1、IDLE状态:查路由表
# 2、active delay计时器到期后开始,
# a.CONNECTED状态:被动建立
# b.ACTIVE状态:主动建立
# 3、TCP三次握手
1615.314333   10.1.23.2   10.1.23.3   TCP 4840501→179 Seq=0 Win=16384 Len=0 MSS=1460
1715.317349   10.1.23.3   10.1.23.2   TCP 48179→40501 Seq=0 Ack=1 Win=16384 Len=0 MSS=1460
1815.318670   10.1.23.2   10.1.23.3   TCP 4440501→179 Seq=1 Ack=1 Win=16384 Len=0

# 4、OPENSEND:发送
1915.329280   10.1.23.2   10.1.23.3   BGP 101 OPEN Message
2015.331753   10.1.23.3   10.1.23.2   TCP 44179→40501 Seq=1 Ack=58 Win=16327 Len=0
2115.338059   10.1.23.3   10.1.23.2   BGP 101 OPEN Message

# OPENSEND messaga的BGP协商;
# a.router-id不能相同;b.AS必须相同;
Frame 19: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface 0
Cisco HDLC
Internet Protocol Version 4, Src: 10.1.23.2, Dst: 10.1.23.3
Transmission Control Protocol, Src Port: 40501, Dst Port: 179, Seq: 1, Ack: 1, Len: 57
Border Gateway Protocol - OPEN Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 57
    Type: OPEN Message (1)
    Version: 4
    My AS: 234
    Hold Time: 180
    BGP Identifier: 2.2.2.2
    Optional Parameters Length: 28
    Optional Parameters

# c.协商holdtime时间较小的;keepalive时间为holdtime的1/3;
IOU2(config-router)#do sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.23.3 remote-as 234
neighbor 10.1.23.3 timers 30 120

Frame 1505: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface 0
Cisco HDLC
Internet Protocol Version 4, Src: 10.1.23.2, Dst: 10.1.23.3
Transmission Control Protocol, Src Port: 57899, Dst Port: 179, Seq: 1, Ack: 1, Len: 57
Border Gateway Protocol - OPEN Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 57
    Type: OPEN Message (1)
    Version: 4
    My AS: 234
    Hold Time: 120
    BGP Identifier: 2.2.2.2
    Optional Parameters Length: 28
    Optional Parameters

# d.协商capability
Border Gateway Protocol - OPEN Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 57
    Type: OPEN Message (1)
    Version: 4
    My AS: 234
    Hold Time: 180
    BGP Identifier: 3.3.3.3
    Optional Parameters Length: 28
    Optional Parameters
      Optional Parameter: Capability
            Parameter Type: Capability (2)
            Parameter Length: 6
            Capability: Multiprotocol extensions capability
                Type: Multiprotocol extensions capability (1)
                Length: 4
                AFI: IPv4 (1)
                Reserved: 00
                SAFI: Unicast (1)
      Optional Parameter: Capability
            Parameter Type: Capability (2)
            Parameter Length: 2
            Capability: Route refresh capability (Cisco)
                Type: Route refresh capability (Cisco) (128)
                Length: 0
      Optional Parameter: Capability
            Parameter Type: Capability (2)
            Parameter Length: 2
            Capability: Route refresh capability
                Type: Route refresh capability (2)
                Length: 0
      Optional Parameter: Capability
            Parameter Type: Capability (2)
            Parameter Length: 2
            Capability: Enhanced route refresh capability
                Type: Enhanced route refresh capability (70)
                Length: 0
      Optional Parameter: Capability
            Parameter Type: Capability (2)
            Parameter Length: 6
            Capability: Support for 4-octet AS number capability
                Type: Support for 4-octet AS number capability (65)
                Length: 4
                AS Number: 234

# BGP协商成功,则进入keepalive;
# BGP协商失败,则进入notification;



# IBGP非直连邻居建立
# a.节省full-mesh互联成本
# b.用Loopback口建立邻居,可以简化配置;
# c.发送数据包源地址为接口地址,根据源检测,需要修改发送TCP源地址为loopback地址;
# neighbor 10.1.2.2 update-source Loopback0;单向neighbor可以建立TCP连接;


IOU2(config-router)#do sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.3.3 remote-as 234
neighbor 10.1.3.3 update-source Loopback0

IOU3(config-router)#do sh run | b r b
router bgp 234
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 10.1.2.2 remote-as 234
neighbor 10.1.2.2 update-source Loopback0




# EBGP直连邻居建立
IOU2#sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.23.3 remote-as 432

IOU3#sh run | b r b
router bgp 432
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 10.1.23.2 remote-as 234

# a.EBGP的TTL为1,建议相邻节点建立EBGP邻居;
Frame 15: 48 bytes on wire (384 bits), 48 bytes captured (384 bits) on interface 0
Cisco HDLC
Internet Protocol Version 4, Src: 10.1.12.1, Dst: 10.1.12.2
    0100 .... = Version: 4
    .... 0101 = Header Length: 20 bytes (5)
    Differentiated Services Field: 0xc0 (DSCP: CS6, ECN: Not-ECT)
    Total Length: 44
    Identification: 0x84f0 (34032)
    Flags: 0x02 (Don't Fragment)
    Fragment offset: 0
    Time to live: 1
    Protocol: TCP (6)
    Header checksum: 0xc817
   
    Source: 10.1.12.1
    Destination: 10.1.12.2
   
   
Transmission Control Protocol, Src Port: 40040, Dst Port: 179, Seq: 0, Len: 0



# EBGP非直连邻居建立
IOU2(config-router)#do sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.3.3 remote-as 432
neighbor 10.1.3.3 update-source Loopback0

IOU3(config-router)#do sh run | b r b
router bgp 432
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 10.1.2.2 remote-as 234
neighbor 10.1.2.2 update-source Loopback0

# a.EBGP直连检测导致不发送TCP连接,无法建立非直连邻居;
IOU3(config-router)#
*Nov 29 02:58:51.881: BGP: 10.1.2.2 Active open failed - no route to peer, open active delayed 7168ms (35000ms max, 60% jitter

# b.直连检测:路由表中是否存在直连路由;减少发送不必要的数据包开销;
# c.EBGP的TTL为1,多个路由器网络无法建立邻居;
IOU2(config-router)#do sh run | b r b
router bgp 234
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 10.1.4.4 remote-as 432
neighbor 10.1.4.4 ebgp-multihop 255
neighbor 10.1.4.4 disable-connected-check
neighbor 10.1.4.4 update-source Loopback0

IOU4(config-router)#do sh run | b r b
router bgp 432
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor 10.1.2.2 remote-as 234
neighbor 10.1.2.2 ebgp-multihop 255
neighbor 10.1.2.2 disable-connected-check
neighbor 10.1.2.2 update-source Loopback0



zhangxiajun 发表于 2017-12-20 09:58:05

学习了
页: [1]
查看完整版本: BGP的邻居建立