使用 BGP
OSPF 大型
ISF 超大型
BGP 巨型(互联网)
单宿主
多宿主
双多宿主
需要使用 BGP 协议的情况
- 设备处理能力,存储空间足够大
- 物理连接不能采用单宿主的连接
- AS间通信,需要设置路由策略时
IGP 协议
内部网关协议 Interior Gateway Protocol 。 AS 内部的协议
- OSPF
- ISIS
- RIP
- EIGRP
EGP 协议
外部网关协议 Exterior Gateway Protocol 。连接不同的AS
自治系统
AS :Autonomous system
2009 年 1 月之前:16 进制数字表示自治号
私有自治号:64512 - 65535
BGP 特征
- TCP port 179
- 增量触发的更新
- 周期性保活(keepalive)
- 每经过一个 AS,称为一跳
- 为巨型网络设计(互联网公网)
BGP 邻居
BGP neighbor also BGP peer (BGP 载体)
IBGP:两台 BGP 对等体属于不同的 AS,必须直连
EBGP:两台 BGP 对等体必须在同一 AS 内,不必直连,但需通过 IBGP 协议可达。
定义 BGP 进程并激活 EBGP 会话
R2(config)#router bgp 65010
R2(config-router)#neighbor 10.1.1.2 remote-as 65020
# 第一种配置:
R2(config-router)#network 10.2.2.0 mask 255.255.255.0
# 第二种配置:从IGP引入
R2(config-router)#redistribute ospf 100
# router bgp xxx 若 xxx 等于 neighbor 10.1.1.2 remote-as yyy 中的 yyy, 则是IBGP。
# 若不等于,则是EBGP
其他配置
# 关闭bgp邻居
R2(config-router)#neighbor 10.1.1.2 shutdown
# 重新开启关闭的bgp邻居
R2(config-router)#no neighbor 10.1.1.2 shutdown
# 修改目的地址
R2(config-router)#neighbor 1.1.1.1 update-source Loopback0
# 修改下一跳地址
R2(config-router)#neighbor 1.1.1.1 next-hot-self
R2(config-router)#no synchronization # IOS v12.2以后自动关闭BGP同步,无需配此条
R2(config-router)#no auto-summary # 关闭BGP自动汇总
R2(config-router)#neighbor 3.3.3.3 ebgp-multihop 2 # 修改跳数为2
R3(config)#router ospf 100
R3(config-router)#redistribute bgp 200 subnets
R2#show ip bgp
R2#show ip bgp neighbor
R2#show ip bgp summary
R2#show ip bgp lib-failure
R2#clear ip bgp * # 慎用!
R2#clear ip bgp 10.1.1.2
R2#clear ip bgp 10.1.1.2 soft out|in
R2(config-router)#neighbor 10.1.1.2 soft-reconfiguration inbound
通过 IBGP 学到的路由在通过 IGP 学到之前不能通告给 EBGP 邻居
路由管理距离值
直连 0
静态 1
EIGRP 90/170
OSPF 110
RIP 120
ISIS 115
EBGP 20
IBGP 200
路由选择的过程
- 根据权重选高的 weight
- 根据本地优先权选高的 preference
- 根据本地路由器生成的路由条目 originated by the local router
- 根据 AS 路径选最短的
- 根据 origin code(来源信息) 选最小的 (IGP < EGP < incomplete)
- 根据 MED(metric) 选最小的
- prefer the EBGP path over the IBGP path
- 选通过最近的 IGP 邻居
- 选 EBGP 路径最老的
- prefer the pathH with the lowest BGP router ID
- lowest neighbor IP address
R2(config)#router-map MY-Router-Map permit 10
R2(config-router-map)#match local-preference 150
R2(config-router-map)#set weight 200
R2(config-router)#neighbor 10.0.0.1 router-map MY-Router-Map in|out
R2(config-router)#ip as-path access-list 10 permit _65020$
起源代码 (IGP < EGP < incomplete) 0<1<2