1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 01 IBGP和EBGP基本配置

01 IBGP和EBGP基本配置

时间:2021-09-08 06:22:58

相关推荐

01 IBGP和EBGP基本配置

01 IBGP和EBGP基本配置

实验目的

通过本实验可以掌握

(1)启动 BGP 路由进程

(2)BGP 进程中通告网络

(3)IBGP 邻居配置

(4)EBGP 邻居配置

(5)BGP 路由更新源配置

(6)next-hop-self 配置

(7)BGP 路由汇总配置

(8)BGP 路由调试

实验拓扑

实验步骤

因为本实验中 IBGP 的路由器(R1,R2 和 R3)形成全互联(FULL MESH)的邻居关系,所以路由器 R1、R2 和 R3 均关闭同步。IBGP 路由器之间运行的 IGP 是 EIGRP,为了提供 BGP 建立邻居关系的 TCP 连接和 BGP 下一跳可达。

1.配置IP地址

# '''R1'''enable conf terminal interface Loopback 0ip address 1.1.1.1 255.255.255.0no shutdown exitinterface fastEthernet 0/0ip address 12.12.12.1 255.255.255.0no shutdownexit# '''R2'''conf tint l0ip add 2.2.2.2 255.255.255.0no shint f0/0ip add 12.12.12.2 255.255.255.0no shint f0/1ip add 23.23.23.2 255.255.255.0no sh# '''R3'''conf tint l0ip add 3.3.3.3 255.255.255.0no shint f0/1ip add 23.23.23.3 255.255.255.0no shint f0/0ip add 34.34.34.3 255.255.255.0no sh# '''R4'''conf tint l0ip add 4.4.0.4 255.255.255.0no shint l1ip add 4.4.1.4 255.255.255.0no shint l2ip add 4.4.2.4 255.255.255.0no shint l3ip add 4.4.3.4 255.255.255.0no shint f0/0ip add 34.34.34.4 255.255.255.0no sh

2.配置EIGRP和BGP协议

# '''R1'''# no synchronization 用于关闭路由同步,实际上默认是关闭的,可以不执行# show run 可以查看路由器上有哪些配置,可以看到synchronization和auto-summary# bgp router-id 1.1.1.1 用于配置router-id,缺省情况下router-id为路由器接口上最大的IP# neighbor 2.2.2.2 remote-as 100 指定邻居路由及所在的AS,并通过AS判断是IBGP邻居还是EBGP邻居# neighbor 2.2.2.2 update-source Loopback0 指定更新源,IBGP在建立邻居的时候指定Loopback口作为更新源可以使链路稳定(AS内部运行的IGP,如ospf,保证了Loopback口可达),而物理链路直连建立的邻居则容易down掉# network 1.1.1.0 mask 255.255.255.0 通告网络# no auto-summary 关闭自动汇总router eigrp 1network 1.1.1.0 255.255.255.0network 12.12.12.0 255.255.255.0no auto-summaryrouter bgp 100no synchronizationbgp router-id 1.1.1.1neighbor 2.2.2.2 remote-as 100neighbor 2.2.2.2 update-source Loopback0neighbor 3.3.3.3 remote-as 100neighbor 3.3.3.3 update-source Loopback0network 1.1.1.0 mask 255.255.255.0no auto-summary# '''R2'''router eigrp 1network 2.2.2.0 255.255.255.0network 12.12.12.0 255.255.255.0network 23.23.23.0 255.255.255.0no auto-summaryrouter bgp 100no synchronizationbgp router-id 2.2.2.2neighbor 1.1.1.1 remote-as 100neighbor 1.1.1.1 update-source Loopback0neighbor 3.3.3.3 remote-as 100neighbor 3.3.3.3 update-source Loopback0no auto-summary# '''R3'''# neighbor 1.1.1.1 next-hop-self 配置下一跳为自己(本地),next-hop 属性遵循以下规则,BGP Speaker 在向 IBGP 对等体发布从 EBGP 对等体学来的路由时,并不改变该路由信息的下一跳属性,这将引起路由黑洞问题,为了解决这一问题,我们使用此命令强迫路由器通告自己是发送 BGP 更新的下一跳,而不是 EBGP 邻居router eigrp 1network 3.3.3.0 255.255.255.0network 23.23.23.0 255.255.255.0no auto-summaryrouter bgp 100no synchronizationbgp router-id 3.3.3.3neighbor 1.1.1.1 remote-as 100neighbor 1.1.1.1 update-source Loopback0neighbor 1.1.1.1 next-hop-selfneighbor 2.2.2.2 remote-as 100neighbor 2.2.2.2 update-source Loopback0neighbor 2.2.2.2 next-hop-selfneighbor 34.34.34.4 remote-as 200no auto-summary# show ip bgp summary 查看bgp邻居表,加上do是为了在config中也可以执行此命令# 此时查看R3的bgp邻居表,可以看到R1、R2已经与R3建立邻居关系,而R4我们还未进行配置,所以State处于Active状态,R3一直在尝试与R4建立邻居关系MsgRcvd、MsgSent分别是发送和接受的报文数,TblVer为TableVersionR3(config-router)#do show ip bgp summaryBGP router identifier 3.3.3.3, local AS number 100BGP table version is 1, main routing table version 1Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd1.1.1.1 4 100 8 7 1 0 0 00:04:08 02.2.2.2 4 100 8 7 1 0 0 00:04:10 034.34.34.44 200 0 0 0 0 0 never Active# '''R4'''# ip route 4.4.0.0 255.255.252.0 null0 用于在IGP表中构造该汇总路由,否则将不能用network通告,即前面的network通告将无效router bgp 200bgp router-id 4.4.4.4neighbor 34.34.34.3 remote-as 100no auto-summarynetwork 4.4.0.0 mask 255.255.255.0network 4.4.1.0 mask 255.255.255.0 network 4.4.2.0 mask 255.255.255.0network 4.4.3.0 mask 255.255.255.0 network 4.4.0.0 mask 255.255.252.0 exitip route 4.4.0.0 255.255.252.0 null0

实验调试

(1) show tcp brief

# 配置完一段时间后将会看到以下输出,表明R3有3条BGP邻居up,一条EIGRP邻居up*Mar 1 00:03:21.483: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 23.23.23.2 (FastEthernet0/1) is up: new adjacency*Mar 1 00:03:39.563: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up *Mar 1 00:03:54.143: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up *Mar 1 00:04:32.555: %BGP-5-ADJCHANGE: neighbor 34.34.34.4 Up # show tcp brief 该命令用来查看 TCP 连接信息摘要R3#show tcp briefTCB Local AddressForeign Address (state)670EAA54 3.3.3.3.179 2.2.2.2.61599ESTAB670EAFB0 3.3.3.3.179 1.1.1.1.62099ESTAB670ED17C 34.34.34.3.60226 34.34.34.4.179 ESTAB# 以上输出标明路由器 R3 和路由器 R1、R2 和 R4 的 179 端口建立了 TCP 连接。建立 TCP连接的双方使用 BGP 路由更新源的地址。只要两台路由器之间建立了一条 TCP 连接,就可以形成 BGP 邻居关系

(2) show ip bgp neighbors

# show ip bgp neighbors 查看邻居的 TCP 和 BGP 连接的详细信息,多页信息显示时可以按q退出R3#show ip bgp neighborsBGP neighbor is 1.1.1.1, remote AS 100, internal linkBGP version 4, remote router ID 1.1.1.1BGP state = Established, up for 00:04:36......R3#show ip bgp neighbor 34.34.34.4BGP neighbor is 34.34.34.4, remote AS 200, external linkBGP version 4, remote router ID 4.4.4.4BGP state = Established, up for 00:04:28Last read 00:00:28, last write 00:00:28, hold time is 180, keepalive interval is 60 secondsNeighbor capabilities:Route refresh: advertised and received(old & new)Address family IPv4 Unicast: advertised and receivedMessage statistics:InQ depth is 0OutQ depth is 0Sent RcvdOpens: 11Notifications:00Updates:11Keepalives: 66Route Refresh:00Total: 88Default minimum time between advertisement runs is 30 secondsFor address family: IPv4 UnicastBGP table version 8, neighbor version 8/0Output queue size: 0......# 以上输出表明路由器有一个外部 BGP 邻居路由器 R4(34.34.34.4)在 AS 200。此邻居的路由器 ID 号是 4.4.4.4。命令“show ip bgp neighbors”显示出的信息最重要的一部分是“BGP state=”那一行。此行给出了 BGP 连接的状态。“Established”状态表示 BGP 对等体间的会话是打开的并正在运行。如果显示的是其它状态,如 Idle、Connect、Active、OpenSent 或 OpenConfirm,那就存在问题

(3) show ip bgp summary

# show ip bgp summary 查看 BGP 连接的摘要信息R3#show ip bgp summaryBGP router identifier 3.3.3.3, local AS number 100 #路由器ID及本地ASBGP table version is 8, main routing table version 8 #BGP表的内部版本号(每次变化递增1),注入到主路由表的最终版本6 network entries using 720 bytes of memory #网络条目和使用的内存6 path entries using 312 bytes of memory #路径条目和使用的内存3/2 BGP path/bestpath attribute entries using 372 bytes of memory #注入的路由和最佳路由条目及所占内存1 BGP AS-PATH entries using 24 bytes of memory0 BGP route-map cache entries using 0 bytes of memory0 BGP filter-list cache entries using 0 bytes of memoryBitfield cache entries: current 2 (at peak 2) using 64 bytes of memoryBGP using 1492 total bytes of memoryBGP activity 6/0 prefixes, 6/0 paths, scan interval 60 secsNeighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd #连接状态/通告的路由前缀1.1.1.1 4 1001010 8 0 0 00:05:47 12.2.2.2 4 1001010 8 0 0 00:06:01 034.34.34.44 200 9 9 8 0 0 00:05:08 5

(4) show ip bgp

# show ip bgp 查看BGP表的信息R3#show ip bgpBGP table version is 8, local router ID is 3.3.3.3Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetworkNext Hop Metric LocPrf Weight Pathr>i1.1.1.0/24 1.1.1.1 0 1000 i*> 4.4.0.0/24 34.34.34.40 0 200 i*> 4.4.0.0/22 34.34.34.40 0 200 i*> 4.4.1.0/24 34.34.34.40 0 200 i*> 4.4.2.0/24 34.34.34.40 0 200 i*> 4.4.3.0/24 34.34.34.40 0 200 i# 以上输出中,路由条目表项的状态代码(Status codes)的含义解释如下:s:表示路由条目被抑制; d:表示路由条目由于被惩罚而受到抑制,从而阻止了不稳定路由的发布; h: 表示该路由该路由正在被惩罚,但还未达到抑制阀值而使它被抑制; *: 表示该路由条目有效; >: 表示该路由条目最优,可以被传递,达到最优的重要前提是下一跳可达; i:表示该路由条目是从 IBGP 邻居学到的; r:表示将 BGP 表中的路由条目放入到 IP 路由表中失败。 # 以上输出中,起源代码(Origin codes)的含义解释如下: i:表示路由条目来源为 IGP; e:表示路由条目来源为 EGP; ?: 表示路由条目来源不清楚,通常是从 IGP 重分布到 BGP 的路由条目。 # 下面具体地解释 BGP 路由条目 "r>i1.1.1.0/24 1.1.1.1 0 1000 i" 的含义: r:因为路由器 R3 通过 EIGRP 学到“1.1.1.0/24”路由条目,其管理距离为 90,而通过 IBGP 学到“1.1.1.0/24”路由条目的管理距离是 200,而且关闭了同步,BGP 表中的路由条目放入到 IP 路由表中失败,所以出现代码“r”; >: 表示该路由条目最优,可以继续传递; i:表示该路由条目是从 IBGP 邻居学到的; 1.1.1.1: 表示该 BGP 路由的下一跳; 0(标题栏对应 Metric): 表示该路由外部度量值即 MED 值为 0; 100:表示该路由本地优先级为 100; 0(标题栏对应 Weight): 表示该路由的权重值为 0,如果是本地产生的,默认权重值是 32768;如果是从邻居学来的,默认权重值为 0; 由于该路由是通过相同 AS 的 IBGP 邻居传递来,所以 PATH 字段为空; i: 表示路由条目来源为 IGP,它是路由器 R1 用“network”命令通告的。

(5) show ip route

# show ip route 查看路由表R1#show ip route Codes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not set1.0.0.0/24 is subnetted, 1 subnetsC 1.1.1.0 is directly connected, Loopback02.0.0.0/24 is subnetted, 1 subnetsD 2.2.2.0 [90/409600] via 12.12.12.2, 00:14:41, FastEthernet0/03.0.0.0/24 is subnetted, 1 subnetsD 3.3.3.0 [90/435200] via 12.12.12.2, 00:13:19, FastEthernet0/04.0.0.0/8 is variably subnetted, 5 subnets, 2 masksB 4.4.0.0/24 [200/0] via 3.3.3.3, 00:11:39B 4.4.0.0/22 [200/0] via 3.3.3.3, 00:11:39B 4.4.1.0/24 [200/0] via 3.3.3.3, 00:11:40B 4.4.2.0/24 [200/0] via 3.3.3.3, 00:11:40B 4.4.3.0/24 [200/0] via 3.3.3.3, 00:11:4023.0.0.0/24 is subnetted, 1 subnetsD 23.23.23.0 [90/307200] via 12.12.12.2, 00:14:46, FastEthernet0/012.0.0.0/24 is subnetted, 1 subnetsC 12.12.12.0 is directly connected, FastEthernet0/0R3#show ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not set34.0.0.0/24 is subnetted, 1 subnetsC 34.34.34.0 is directly connected, FastEthernet0/01.0.0.0/24 is subnetted, 1 subnetsD 1.1.1.0 [90/435200] via 23.23.23.2, 00:13:57, FastEthernet0/12.0.0.0/24 is subnetted, 1 subnetsD 2.2.2.0 [90/409600] via 23.23.23.2, 00:13:57, FastEthernet0/13.0.0.0/24 is subnetted, 1 subnetsC 3.3.3.0 is directly connected, Loopback04.0.0.0/8 is variably subnetted, 5 subnets, 2 masksB 4.4.0.0/24 [20/0] via 34.34.34.4, 00:12:18B 4.4.0.0/22 [20/0] via 34.34.34.4, 00:12:18B 4.4.1.0/24 [20/0] via 34.34.34.4, 00:12:18B 4.4.2.0/24 [20/0] via 34.34.34.4, 00:12:18B 4.4.3.0/24 [20/0] via 34.34.34.4, 00:12:.0.0.0/24 is subnetted, 1 subnetsC 23.23.23.0 is directly connected, FastEthernet0/112.0.0.0/24 is subnetted, 1 subnetsD 12.12.12.0 [90/307200] via 23.23.23.2, 00:14:02, FastEthernet0/1# 以上输出表明IBGP的管理距离是200,EBGP的管理距离是20,EIGRP的管理距离是90

(6) ping

在路由器R1 上ping 4.4.0.4,结果是不通的,原因很简单,就是路由器R1 和R2 的路由表中没有到34.34.34.0 的路由,此时如果执行扩展ping,就是通的,如果一定要标准ping 的话,无非就是让路由器R1 和R2 学到“34.34.34.0”的路由,

方法很多,比如在路由器R3 上重分布直连。

R1#ping 4.4.0.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 4.4.0.4, timeout is 2 seconds:.....Success rate is 0 percent (0/5)R1#pingProtocol [ip]: Target IP address: 4.4.0.4Repeat count [5]: 2Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: ySource address or interface: 1.1.1.1Type of service [0]: Set DF bit in IP header? [no]: Validate reply data? [no]: Data pattern [0xABCD]: Loose, Strict, Record, Timestamp, Verbose[none]: Sweep range of sizes [n]: Type escape sequence to abort.Sending 2, 100-byte ICMP Echos to 4.4.0.4, timeout is 2 seconds:Packet sent with a source address of 1.1.1.1 !!Success rate is 100 percent (2/2), round-trip min/avg/max = 32/46/60 msR1#ping 4.4.0.4 source 1.1.1.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 4.4.0.4, timeout is 2 seconds:Packet sent with a source address of 1.1.1.1 !!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 20/37/56 ms'''R4同理'''R4#ping 1.1.1.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:.....Success rate is 0 percent (0/5)R4#ping 1.1.1.1 source 4.4.0.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:Packet sent with a source address of 4.4.0.4 !!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 16/30/40 msR4#show ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not set34.0.0.0/24 is subnetted, 1 subnetsC 34.34.34.0 is directly connected, FastEthernet0/01.0.0.0/24 is subnetted, 1 subnetsB 1.1.1.0 [20/0] via 34.34.34.3, 00:24:384.0.0.0/8 is variably subnetted, 5 subnets, 2 masksC 4.4.0.0/24 is directly connected, Loopback0S 4.4.0.0/22 is directly connected, Null0C 4.4.1.0/24 is directly connected, Loopback1C 4.4.2.0/24 is directly connected, Loopback2C 4.4.3.0/24 is directly connected, Loopback3

(7) 在R1上打开BGP同步,然后查看BGP表

'''R1'''# clear ip bgp * 硬重置所有BGP会话,perform a hard reset of all current BGP sessionsconf trouter bgp 100synchronizationexitexitclear ip bgpshow ip bgp# clear之后邻居会down掉,等待重新up后查看bgp路由表R1#clear ip bgp *R1#*Mar 1 00:37:30.563: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down User reset*Mar 1 00:37:30.567: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Down User resetR1#*Mar 1 00:37:50.631: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up *Mar 1 00:37:50.675: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up R1#show ip bgpBGP table version is 2, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetworkNext Hop Metric LocPrf Weight Path*> 1.1.1.0/24 0.0.0.0 0 32768 i* i4.4.0.0/24 3.3.3.3 0 1000 200 i* i4.4.0.0/22 3.3.3.3 0 1000 200 i* i4.4.1.0/24 3.3.3.3 0 1000 200 i* i4.4.2.0/24 3.3.3.3 0 1000 200 i* i4.4.3.0/24 3.3.3.3 0 1000 200 i# 以上输出表明,4.4.0.0/22的这些路由不是被优化的,因为IGP的路由表中没有这些路由条目

(8)删除R1与R3的IBGP邻居关系,验证IBGP水平分割原理

# 断开R1与R3的IBGP邻居关系R1(config)#router bgp 100R1(config-router)#no synchronizationR1(config-router)#no neighbor 3.3.3.3R3(config)#router bgp 100 R3(config-router)#no neighbor 1.1.1.1# 查看R1和R2的BGP表R1(config-router)#do show ip bgpBGP table version is 2, local router ID is 1.1.1.1Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetworkNext Hop Metric LocPrf Weight Path*> 1.1.1.0/24 0.0.0.0 0 32768 iR2#show ip bgpBGP table version is 11, local router ID is 2.2.2.2Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,r RIB-failure, S StaleOrigin codes: i - IGP, e - EGP, ? - incompleteNetworkNext Hop Metric LocPrf Weight Pathr>i1.1.1.0/24 1.1.1.1 0 1000 i*>i4.4.0.0/24 3.3.3.3 0 1000 200 i*>i4.4.0.0/22 3.3.3.3 0 1000 200 i*>i4.4.1.0/24 3.3.3.3 0 1000 200 i*>i4.4.2.0/24 3.3.3.3 0 1000 200 i*>i4.4.3.0/24 3.3.3.3 0 1000 200 i# 以上输出表明路由器R2 并没有将路由器R3 通告的路由通告给路由器R1,这也进一步验证了IBGP 水平分割的基本原理:通过IBGP 学到的路由不能通告给相同AS内的其它的IBGP邻居。通常的解决办法有两个:IBGP 形成全互联邻居关系或使用路由反射器

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。
相关阅读
IBGP 与 EBGP

IBGP 与 EBGP

2020-05-19

EBGP与IBGP

EBGP与IBGP

2023-02-14

理解eBGP和iBGP

理解eBGP和iBGP

2022-04-24

EBGP vs IBGP

EBGP vs IBGP

2021-12-06