![建立IBGP邻居_职场](https://s2.51cto.com/attachment/201009/201009241285291436468.jpg?x-oss-process=image/resize,m_fixed,w_1184)
第一步 预配置
R1(config)#int s2/1
R1(config-if)#ip add
R1(config-if)#no sh
R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#router ospf 1
R1(config-router)#net 0.0.0.0 0.0.0.0 area 0
R1(config-router)#end
R2(config-if)#ip add
R2(config-if)#no sh
R2(config-if)#int s2/2
R2(config-if)#ip add 23.0.0.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#router ospf 1
R2(config-router)#net 0.0.0.0 0.0.0.0 area 0
R2(config-router)#end
R3(config-if)#ip add
R3(config-if)#no sh
R3(config-if)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#router ospf 1
R3(config-router)#net 0.0.0.0 0.0.0.0 area 0
R3(config-router)#end
R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] vi
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/129] vi
23.0.0.0/24 is subnetted, 1 subnets
O 23.0.0.0 [110/128] vi
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
O 1.1.1.1 [110/65] vi
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/65] vi
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
O 1.1.1.1 [110/129] vi
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] vi
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O 12.0.0.0 [110/128] vi
Sending 5, 100-byte ICMP Echos to
Packet sent with a source address of 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/45/68 ms
R1#conf t
R1(config)#router bgp 64521
R1(config-router)#neighbor
R1(config-router)#neighbor 3.3.3.3 update-source lo0
R1(config-router)#end
R3(config)#router bgp 64521
R3(config-router)#neighbor
R3(config-router)#neighbor 1.1.1.1 update-source lo0
R3(config-router)#end
// 如果不指定update-source路由器只能使用到对等路由器最近的IP接口,使用任何时候都正常工作的回环接口提供了BGP的稳定性,即使到最近接口的链路失效了仍然可以维持BGP连接。另外,因为EBGP会话通常是点对点的,所以不需要在EBGP中使用该命令
R1#show ip bgp summary
BGP router identifier
BGP table version is 1, main routing table version 1
BGP router identifier
BGP table version is 1, main routing table version 1
R3#
R3#show ip bgp neighbors
BGP neighbor is 1.1.1.1, remote AS 64521, internal link
BGP version 4, remote router ID 1.1.1.1
BGP state = Established, up for 00:04:43
// 目前状态Established
BGP邻居之间共有6种状态:1. Idle 查找路由表;2. Connect 找到路由表后进行TCP三次握手 ;3. Active 连接TCP握手失败;4. Open Sent 握手后发送Open Message;5. Open Confirm 确认收到对方发来的Open消息;6. Established 会话建立,交换信息
Last read 00:00:42, last write 00:00:42, 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: 6 6
Route Refresh: 0 0
Total: 7 7
Default minimum time between advertisement runs is 0 seconds
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
Local Policy Denied Prefixes: -------- -------
Total: 0 0
Number of NLRIs in the update sent: max 0, min 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 255
Local host:
// BGP使用基于TCP的179端口
Foreign host: 1.1.1.1, Foreign port: 33992
Timer Starts Wakeups Next
Retrans 7 0 0x0
TimeWait 0 0 0x0
AckHold 7 6 0x0
SendWnd 0 0 0x0
KeepAlive 0 0 0x0
GiveUp 0 0 0x0
PmtuAger 0 0 0x0
DeadWait 0 0 0x0
irs: 1759342839 rcvnxt: 1759342999 rcvwnd: 16225 delrcvwnd: 159
minRTT: 56 ms, maxRTT: 300 ms, ACK hold: 200 ms
Flags: passive open, nagle, gen tcbs
IP Precedence value : 6
Rcvd: 13 (out of order: 0), with data: 7, total data bytes: 159
Sent: 13 (retransmit: 0, fastretransmit: 0, partialack: 0, Second Congestion: 0), with data: 6, total data bytes: 159
R1(config)#router bgp 64521
R1(config-router)#net
R1(config-router)#end
R1#show ip bgp
BGP table version is 2, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
*>
R1#show ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
Local
0.0.0.0 from 0.0.0.0 (1.1.1.1)
Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
BGP table version is 3, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
r>i
// r-RIB-failure 放置路由表失败
R3#show ip bgp rib-failure
Network Next Hop RIB-failure RIB-NH Matches
1.1.1.1/32 1.1.1.1 Higher admin distance n/a
// 原因是IBGP的管理距离更高
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
O 1.1.1.1 [110/129] vi
// 可以看到这条路由用的是OSPF的并没有用BGP的,因为OSPF的管理距离为110,小于IBGP的管理距离200
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] vi
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O 12.0.0.0 [110/128] vi