
BGP-概述
- AS(Autonomous System,自治系统)
长度 16 bit,范围 1-65535
公有AS 范围 1-64511
私有AS 后1024个 范围 64512-65535
扩展4字节的AS号
BGP speaker :发布BGP路由的路由器
2.BGP互传AS之间的信息
基于TCP 179
单播精确转发
高级路径矢量路由协议
发布信息 路由信息 + 路由属性
增量式触发更新
3.对等体
消息报文:
Type | 名称 | 作用 |
1 | Open | 协商参数 |
2 | Update | 更新路由 |
3 | Notification | 如果故障,发送通知报错、然后断开连接 |
4 | Keepalive | 维系, KA=1/3 holdtime,holdtime=180sec |
5 | route-refresh | 路由刷新 ①软清,触发update ②ORF(出向路由过滤) 优化 |
3.1 邻居状态机 /建立过程
实验:
R1:
int g0/0/0
ip add 12.1.1.1 24
bgp 100
router-id 1.1.1.1
peer 12.1.1.2 as-number 200 ---指定邻居的通讯地址
R2:
int g0/0/0
ip ad 12.1.1.2 24
bgp 200
router-id 2.2.2.2
peer 12.1.1.1 as-number 100
<r1>terminal debugging --- 将debug信息显示</r1>
Info:
Current terminal debugging is on.
<r1>debugging bgp event ----调测BGP事件状态</r1>
<r1>reset bgp all --重置BGP</r1>
<r1>undo debugging all --关闭所有debug信息</r1>
Info:
All possible debugging has been turned off
3.2 影响邻居建立的参数,如何排障
第一点:互指地址,指对
第二点:互指AS-号指对
第三点:router-id不冲突
实验一:误修改R1的router-id 2.2.2.2
实验二:误修改R1指向R2的邻居as为222
[R1]bgp 100
[R1-bgp]router-id
1.1.1.1
[R1-bgp]undo peer
12.1.1.2
[R1-bgp]peer
12.1.1.2 as-number 222
R2明知道是R1的问题,但是联系不上R1的工程师,如何处理?
临时解决方案
将错就错:R2:
bgp 200
peer 12.1.1.1 fake-as 222 --欺骗R1本地就属于AS222
邻居故障,排错步骤:
第一步:display bgp peer ,查看本地配置的参数
第二步: 本地使用自己的更新源ping测试
检查双方是否可达
R1: ping 12.1.1.2
如果不可达,那么检查IGP网络
如果是EBGP PEER,考虑TTL的问题
第三步:display bgp error ,是否错误的参数配置
收到了哪些错误的报文参数
第四步: 进入bgp视图,dis this
4.BGP Peer
4.1 EBGP
建议:使用物理接口直连组网 作为更新源
原因:①EBGP 消息的TTL默认=1
②AS间建立,需要提高故障的灵敏度
更新源接口物理直连,故障,立即断开邻居,不需要等待holdtime
4.2 IBGP
建立:使用loopback接口作为更新源
原因:①IBGP 消息的TTL默认255
② loopback 接口比物理接口更加稳定
实验:EBGP用lo0建链,那么需要设置EBGP 多跳
R1:
int lo0
ip ad 1.1.1.1 32
ip route-static 2.2.2.2 32 12.1.1.2
bgp 100
undo peer 12.1.1.2
peer 2.2.2.2 as 200
peer 2.2.2.2 connect-interface lo0 --修改本地的更新源接口
peer 2.2.2.2 ebgp-max-hop 2 --发消息给R2时,TTL=2
R2:
int lo0
ip ad 2.2.2.2 32
ip route-static 1.1.1.1 32 12.1.1.1
bgp 200
undo peer 12.1.1.1
peer 1.1.1.1 as 100
peer 1.1.1.1 con lo0
peer 1.1.1.1 ebgp-max-hop --发消息给R2时,默认TTL=255
查看邻居是否建立成功
实验:建立IBGP Peer
第一步:设置AS200内的IGP协议,选用ospf,让设备之间lo0可达
R2:
ospf router-id 2.2.2.2
area 0
int g0/0/1
ip ad 23.1.1.2 24
ospf en 1 a 0
int lo0
ospf en 1 a 0
R3:
ospf router-id 3.3.3.3
area 0
int g0/0/0
ip ad 23.1.1.3 24
ospf en 1 a 0
int g0/0/1
ip ad 34.1.1.3 24
ospf en 1 a 0
R4:
ospf router-id 4.4.4.4
area 0
int g0/0/0
ip ad 34.1.1.4 24
ospf en 1 a 0
int lo0
ip ad 4.4.4.4 32
ospf en 1 a 0
第二步:R2、R4使用lo0建链
R2:
bgp 200
peer 4.4.4.4 as-number 200
peer 4.4.4.4 con lo0
R4:
bgp 200
router-id 4.4.4.4
peer 2.2.2.2 as 200
peer 2.2.2.2 con lo0
BGP-路由传递
使用update 发布bgp的路由。
BGP不产生路由,仅是路由的搬运工
1.路由引入进BGP
1.1 精确引入
一条一条引入
“network”
宣告的是自己RIB中存在的路由
1.2 批量的引入
“import-route”
可以通过route-policy筛选过滤
R1:精确宣告
int lo11
ip ad 192.168.11.1 24
bgp 100
net 192.168.11.0 24
R4:批量引入,使用route-policy筛选
int lo14
ip add 192.168.14.1 24
route-policy DIR permit node 10
if-match int lo14
bgp 200
import-route direct route-policy DIR
查看: display bgp routing-table
2.BGP RIB
[R1]dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d -
damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? -
incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 192.168.11.0 0.0.0.0 0 0 i
*> 192.168.14.0 2.2.2.2 0 200?
① 下一跳属性
0.0.0.0 -- 本地引入进BGP,自己将igp的网络搬入到bgp的路由中
在本地路由表总数 没有增加
127.0.0.1 ---自己bgp产生的路由,非IGP的路由,装在RIB,RIB路由数量增加
其他非零值 --- 从邻居学习得到
②origin :起源
标识最开始如何带入到bgp
i - IGP, network
e - EGP, 从EGP邻居学习
? - incomplete ,import-route引入
③as-path 记录路由传递的AS路径
默认按序记录
最左:最新经过
最右:最早经过
传出AS、传递EBGP Peer,as-path在最左记录本AS
3.路由表中下一跳属性的问题
3.1 本地引入的路由发布出去,nh改为自己的更新源地址
3.2 路由发布给IBGP Peer,AS内传递,nh不变 (想让AS内的BGP路由器直接找到最佳路径,“LSA5 forwarding address”)
3.3 路由发布给EBGP Peer,跨AS传递,nh改变为出设备的更新源地址
[R4]dis bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid 有效, > - best 最棒, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? -
incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
i 192.168.11.0 1.1.1.1 0 100 0 100i
*> 192.168.14.0 0.0.0.0 0 0 ?
-
- valid 有效 : 下一跳可达
- best 最棒 : 选举最优的路径
*> 有效最优路径,发布给邻居、注入到本地RIB指导自己的数据转发
可能出现:
-
_ _ 无效,肯定不是best
-
*_ 有效,但是次优
-
*> 有效且最优
解决方案:
ASBR指IBGP Peer,自觉的配上
[R2]bgp 200
[R2-bgp]peer 4.4.4.4 next-hop-local --发布路由给R4时,下一跳改为自己
现象:两侧网络无法通讯,路由信息单播给BGP 路由器,中间非BGP设备转发bgp包,学习不到BGP RIB。
但是数据转发迭代经过物理设备,经过非BGP设备,“路由黑洞问题”