思科BGP技术详解二
![]() |
五、配置:
只要TCP可达,邻居关系就可以建立。BGP是通过TCP建立的。要建立BGP邻居,必须保证TCP可达,必须路由是可达的。
先建立邻居:
R1#router bgp 100 (一个路由器上只能配置一个AS,否则会提示是:BGP is already running AS is 100 )
Neighbor 12.1.1.2 remote-as 200 指定邻居关系,指定远端的AS号(也就是对端的AS号)
注:在bgp路由器上也有router ID ,选举规则是和OSPF一样的,也可以手动指router ID。
Router bgp 100
Bgp router-id 1.1.1.1
R2#router bgp 200
Neighbor 12.1.1.1 remote-as 100
Bgp router-id 2.2.2.2.
R1上配置完后提示:neighbor 12.1.1.2 up
R1#show ip bgp neighbors
BGP neighbor is 12.1.1.2, remote AS 200, external link外部链路(即是EBGP)
R1的邻居的12.1.1.2,远端的AS是200,
BGP version 4, remote router ID 2.2.2.2
本是,2000年集本升级。远端的ROUTER ID
BGP state = Established, up for 00:00:17
BGP状态:看到Established时,表示和邻居关系已经建立。
Last read 00:00:17, last write 00:00:17, hold time is 180, keepalive interval is 60 seconds
Keepalive保持TCP的连接,保活消息:时间周期60s
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: 1 1
Route Refresh: 0 0
Total: 2 2
Default minimum time between advertisement runs is 30 seconds
For address family: IPv4 Unicast
BGP table version 1, neighbor version 0/0
BGP table version 1:BGp表默认1,每变化一次增加1.如果BGP建立的时间非常短,Version非常高,说明网络变化非常频繁,不稳定。可以进R2的router bgp 200下,neighbor 12.1.1.1 shut,然后再打开,这样经过几次来试验,再看此号,变化了。
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
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: 12.1.1.1, Local port: 43320
Foreign host: 12.1.1.2, Foreign port: 179
Connection tableid (VRF): 0
Enqueued packets for retransmit: 0, input: 0 mis-ordered: 0 (0 bytes)
Event Timers (current time is 0x128AAC):
Timer Starts Wakeups Next
Retrans 3 0 0x0
TimeWait 0 0 0x0
AckHold 1 0 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: 1734781539 snduna: 1734781604 sndnxt: 1734781604 sndwnd: 16320
irs: 3945826168 rcvnxt: 3945826233 rcvwnd: 16320 delrcvwnd: 64
SRTT: 99 ms, RTTO: 1539 ms, RTV: 1440 ms, KRTT: 0 ms
minRTT: 76 ms, maxRTT: 300 ms, ACK hold: 200 ms
Status Flags: active open
Option Flags: nagle
IP Precedence value : 6
Datagrams (max data segment is 1460 bytes):
Rcvd: 4 (out of order: 0), with data: 2, total data bytes: 64
Sent: 4 (retransmit: 0, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 2, total data bytes: 64
Packets received in fast path: 0, fast processed: 0, slow path: 0
Packets send in fast path: 0
fast lock acquisition failures: 0, slow path: 0
R1#show ip bgp summary 查看邻居的汇总信息
BGP router identifier 1.1.1.1, local AS number 100
本地Router id 1.1.1.1 本地的AS 是 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.1.1.2 4 200 18 18 1 0 0 00:15:59 0 如果是数字,表示邻居已建立
在每台路由器上各启一个loop 0
R1#int loop 0
Ip addr 1.1.1.1 255.255.255.0
Router bgp 100
Network 1.1.1.0 mask 255.255.255.0 仅仅将网络加入到BGP域
R2#int loop 0
Ip addr 2.2.2.2 255.255.255.0
Router bgp 200
Network 1.1.1.0 mask 255.255.255.0
R1# show ip router 应该出现:
B 2.2.2.0 [20/0] via 12.1.1.2, 00:00:24
12.0.0.0/24 is subnetted, 1 subnets 收到一条B路由。是通过“ B- BGP”学到的。
R3:启一个loop 0 启AS 300
Int loop 0
Ip address 3.3.3.3. 255.255.255.0
Router bgp 300
Neighbot 23.1.1.1 romote-as 200
Bgp router-id 3.3.3.3
Network 3.3.3.0 mask 255.255.255.0
R3#Show ip bgp nei
只要:State/pfxrcd 是个数字,是邻居建立了。
R1#show ip route
学到了两条B路由:
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [20/0] via 12.1.1.2, 00:24:38
是通过EBGP学来的距离是20,IBGP是200.
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 12.1.1.2, 00:00:08
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, FastEthernet0/0
六、此试验全部的配置总结:
R1#int loop 0 Ip addr 1.1.1.1 255.255.255.0
Int f0/0 Ip addr 12.1.1.1 255.255.255.0
No shut
router bgp 100 注:一个路由器上只能配置一个AS号。
Network 1.1.1.0 mask 255.255.255.0
Bgp router-id 1.1.1.1
Nei 12.1.1.1 remote-as 200
R2#int loop 0 Ip addr 2.2.2.2 255.255.255.0
Int f0/0 Ip addr 12.1.1.2 255.255.255.0
Int f0/1 Ip addr 23.1.1.1 255.255.255.0
No shut
Router bgp 200
Neighbor 12.1.1.1 remote-as 100
Neighbor 23.1.1.2 remoe-as 300
Bgp router-id 2.2.2.2.
R3:Int loop 0 Ip address 3.3.3.3. 255.255.255.0
Router bgp 300
Neighbot 23.1.1.1 romote-as 200
Bgp router-id 3.3.3.3
Network 3.3.3.0 mask 255.255.255.0
注:R1、R2、R3只是用neibghor建立了邻居关系,并没把所连接的端口的地址加入到bgp域中,通过在R1上show ip route ,看出R1能学到2.0和3.0的网络,说明了:1.0到达3.0是通过neighbor建立的邻居关系,再通过bgp的承载到达的。
如果把R2的FO/0接口shutdown,到R1上查看bgp表:show ip bgp sum显示:状态是Active.
R1#show ip bgp summ
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.1.1.2 4 200 26 26 0 0 0 00:00:07 Active
暂时还木有人评论,坐等沙发!