验证理论

Ⅰ.BGP特性

  1.1 BGP同步

    BGP同步规则是指:当一台路由器从自己的IBGP对等体学习到一条BGP路由时(这类路由被称为IBGP路由),它将不能使用该条路由或者把这条路由通告给自己的EBGP对等体,除非它又从IGP协议(例如OSPF等,此处也包含静态路由)学习到这条路由,也就时要求IBGP路由与IGP路由同步。同步规则主要用于规避BGP路由黑洞问题

    注释:BGP设备将最优路由加入BGP路由表,形成BGP路由

        标识为“>”的路由必须满足以下条件

          1.BGP Next-hop可达

          2.BGP同步禁用

  1.2 BGP over  GRE

Ⅱ.BGP聚合

  2.1 手动聚合(as-set,detail-suppress,origin-policy,suppress-policy,attribute-policy)默认聚合不会抑制明细,不携带明细AS  

  2.2 自动聚合(本地IGP条目,import-route引入)

Ⅲ.BGP过滤

  3.1 ACL,ip-prefix

  3.2 filter-policy

  3.3 route-policy

  3.4 ORF  

 

 

 

Ⅰ.BGP特性

1.1BGP同步

实验拓扑(华为不支持开启同步功能,所以只能用GNS3模拟)

BGP 路由过虑 bgp路由过滤_sed

 

 

 

初始配置 

在AS100内运行ISIS。AS之间建立EBGP邻居关系,AS内部R2,4之间建立IBGP邻居关系。R3未配置BGP功能。在AR2和AR4上未开启同步功能,在AR2上面向R4的邻居,指定下一跳为自己。

R1#sh run | s bgp
router bgp 200
no synchronization
network 10.1.1.1 mask 255.255.255.255
neighbor 155.1.12.2 remote-as 100

R2#sh run | s bgp
router bgp 100
no synchronization
neighbor 155.1.12.1 remote-as 200
neighbor 155.1.34.4 remote-as 100
neighbor 155.1.34.4 next-hop-self

 

R4#sh run | s bgp
router bgp 100
no synchronization
neighbor 155.1.23.2 remote-as 100
neighbor 155.1.45.5 remote-as 200

 

R5#sh run | s bgp
router bgp 200
no synchronization
neighbor 155.1.45.4 remote-as 100
neighbor 155.1.45.4 allowas-in

 

初始结果:

R5#sh i
*Mar 1 00:18:02.155: %SYS-5-CONFIG_I: Configured from console by console
R5#sh ip bgp
BGP table version is 2, local router ID is 155.1.45.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.1/32 155.1.45.4 0 100 200 i

 

实验目的:

1.验证开启同步之后,因为从IBGP学到的路由没有从IGP再次学到,所以不会使用这条路由,也不会将这条路由传递给EBGP邻居

2.验证开启同步之后,手动设置从IBGP学到的路由再从IGP学到,路由条目正常传递

 

实验步骤:

第一步:

R2,4开启同步功能

R2(config-router)#synchronization 

R4(config-router)#synchronization 

此时查看R4上的10.1.1.1的路由即使下一跳可达也已经不是最优的了,R5上也没有10.1.1.1的路由了

R4#sh ip bgp
BGP table version is 5, local router ID is 150.1.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
* i10.1.1.1/32 155.1.23.2 0 100 0 200 i
R4#ping 155.1.23.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 155.1.23.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/59/64 ms

R5#sh ip bgp

R5#

 

第二步:

在R4上添加一条10.1.1.1的静态路由,使得他也被IGP学到

R4(config)#ip route 10.1.1.1 255.255.255.255 null 0

稍等一会儿之后再查看表象,AR4,5上又都有了10.1.1.1的路由

R4#sh ip bgp
BGP table version is 7, local router ID is 150.1.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
r>i10.1.1.1/32 155.1.23.2 0 100 0 200 i
R4#

R5#sh ip bgp
BGP table version is 4, local router ID is 155.1.45.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.1/32 155.1.45.4 0 100 200 i
R5#

 

  同步属性是为了防路由黑洞(比如说AS内部必经路径上没有配置BGP)而设置,但是仅仅是为了防止黑洞,就将公网的几十万条路由引入到IGP协议中是不现实的,所以后面同步被取消,采用了其他方法来突破路由黑洞

 

 

 

 

实验拓扑:

BGP 路由过虑 bgp路由过滤_Network_02

 

 初始配置:

AR1,5上引入的10.1.x.x可以相互学习到,AR3上没有配置BGP。配置不再重复粘贴,不了解可以看下上一篇BGP路由传递+破除EBGP防环机制+破除IBGP防环机制

初始结果:

[AR5]dis bgp routing-table

*> 10.1.1.1/32 155.1.45.4 0 100 200i
*> 10.1.5.5/32 0.0.0.0 0 0 i

[AR1]dis bgp routing-table

*> 10.1.1.1/32 0.0.0.0 0 0 i
*> 10.1.5.5/32 150.1.2.2 0 100 200i

但是因为必经之路AR3上没有起BGP,没有10段路由,所以此时AR1和AR5之间是ping不通的

[AR3]dis ip routing-table | in 10.1.
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13

Destination/Mask Proto Pre Cost Flags NextHop Interface

[AR3]

[AR1]ping -c 2 -a 10.1.1.1 10.1.5..5
Error: Unknown host 10.1.5..5.
[AR1]ping -c 2 -a 10.1.1.1 10.1.5.5
PING 10.1.5.5: 56 data bytes, press CTRL_C to break
Request time out
Request time out

 

 

 

一.

实验目的:

用BGP over GRE实现不在AR3上增加BGP,使得AR1,5之间通信

 

实验步骤:

增设隧道,重新指定peer

[AR2]int Tunnel 0/0/0
[AR2-Tunnel0/0/0]ip add 9.9.9.9 24
[AR2-Tunnel0/0/0]tunnel-protocol gre
[AR2-Tunnel0/0/0]source 150.1.2.2
[AR2-Tunnel0/0/0]destination 150.1.4.4

[AR2-bgp]peer 9.9.9.10 as-number 100
[AR2-bgp]peer 9.9.9.10 connect-interface Tunnel 0/0/0
[AR2-bgp]peer 9.9.9.10 next-hop-local

 

[AR4]int Tunnel 0/0/0
[AR4-Tunnel0/0/0]ip add 9.9.9.10 24
[AR4-Tunnel0/0/0]tunnel-protocol gre
[AR4-Tunnel0/0/0]source 150.1.4.4
[AR4-Tunnel0/0/0]destination 150.1.2.2

[AR4-bgp]peer 9.9.9.9 as-number 100
[AR4-bgp]peer 9.9.9.9 connect-interface Tunnel 0/0/0
[AR4-bgp]peer 9.9.9.9 next-hop-local

测试结果:此时AR1去往AR5,在AR2上查找路由表,发现下一跳时隧道接口,所以被GRE重新封装源IP 150.1.2.2,目的IP 150.1.4.4,查询目的地址150.1.4.4的路由,从0/0/1传递给AR3,AR3上是有150.1.4.4的路由的,所以传递给了AR4,AR4剥离封装的源目IP,传递给AR5,反向过程类似

[AR1]ping -c 2 -a 10.1.1.1 10.1.5.5
PING 10.1.5.5: 56 data bytes, press CTRL_C to break
Reply from 10.1.5.5: bytes=56 Sequence=1 ttl=253 time=50 ms
Reply from 10.1.5.5: bytes=56 Sequence=2 ttl=253 time=40 ms

BGP 路由过虑 bgp路由过滤_路由表_03

 

[AR2]DIS IP routing-table 10.1.5.5
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface

10.1.5.5/32 IBGP 255 0 RD 9.9.9.10 Tunnel0/0/0

 

查看有哪些数据会被重新封装,只需要查找路由表,看哪些路由条目下一跳时tunnel即可(实际只是类似于新增了一个端口,如果不主动调用这个端口或者这个端口的地址,是不会往这边走的)

[AR2]dis ip routing-table | in Tunnel0/0/0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 20 Routes : 20

Destination/Mask Proto Pre Cost Flags NextHop Interface

9.9.9.0/24 Direct 0 0 D 9.9.9.9 Tunnel0/0/0
9.9.9.9/32 Direct 0 0 D 127.0.0.1 Tunnel0/0/0
9.9.9.255/32 Direct 0 0 D 127.0.0.1 Tunnel0/0/0
10.1.5.5/32 IBGP 255 0 RD 9.9.9.10 Tunnel0/0/0

[AR2]

所谓BGP over GRE.其实除了创建隧道本身,只是在指定peer的时候用了一下对端隧道接口而已。使得去往对端的数据包被GRE重新封装源目IP,便于被没有BGP的AR3转发

 

 

 

Ⅱ.BGP聚合

实验目的:

1.1 手动聚合,验证手动聚合相关属性

  手动聚合可以对本地加载的路由做聚合,也可以对邻居接收的路由做聚合(当然不管是本地加载的,还是邻居接收的,肯定要有明细,没有明细肯定使用不了)

 

实验步骤:

第一步:创建一个没有明细路由的聚合路由,发现即使可以创建成功,但是dis bgp routing的时候并不在表项中

[AR4-bgp]aggregate 5.5.5.0 24
[AR4-bgp]dis bgp rout
[AR4-bgp]dis bgp routing-table

BGP Local router ID is 155.1.45.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 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.5/32 155.1.45.5 0 0 200i

 

第二步:删除上面的没有明细的聚合路由,新增10.1.5.0/24的聚合路由,不携带任何参数。

  1.发现明细和聚合路由都在bgp路由表中,且也都还是带着best

  2.发现AR4上在将聚合路由载入路由表时,自动将出接口变为null0防环,但是仍然无法防止路由回馈

  3.只要有一条明细路由是通过import-router进来的(import-route起源属性为?,network起源属性为i),聚合路由的起源属性就是?

[AR4-bgp]aggregate 10.1.5.0 24

[AR4-bgp]dis bgp routing-table

BGP Local router ID is 155.1.45.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: 3
Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 i
*> 10.1.5.5/32 155.1.45.5 0 0 200i

此时不带任何参数手动聚合了路由之后,明细和汇总路由都在路由表中

 

因为聚合路由是本地生成的,下一跳是127.0.0.1,默认也不携带明细AS-PATH,且他是最优的,所以他会向AR5发送

[AR4-bgp]dis ip routing-table | in 10.1.5

10.1.5.0/24 IBGP 255 0 D 127.0.0.1 NULL0
10.1.5.5/32 EBGP 255 0 D 155.1.45.5 GigabitEthernet0/0/0

[AR4]dis bgp routing-table peer 155.1.45.5 advertised-routes

BGP Local router ID is 155.1.45.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 10.1.1.1/32 155.1.45.4 0 100 200i
*> 10.1.5.0/24 155.1.45.4 0 100i

但是由于有空接口的存在,此时无法产生环路:比如在AR5上ping一个不存在的10.1.5.7.AR5查路由表,根据汇总路由传递给AR4,AR4再查路由表,根据汇总路由就扔进了null 0

 

原先dis bgp routing-table看到唯一的明细路由的起源属性为i,即这条10.1.5.5是通过network方式引入的,增加一条起源属性为?即通过import-route引入的路由,发现汇总路由的起源属性也变成了?

[AR5]ip route-static 10.1.5.55 32 null 0
[AR5]bgp 200
[AR5-bgp]import-route static

 

[AR4]dis bgp routing-table

BGP Local router ID is 155.1.45.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: 4
Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 ?
*> 10.1.5.5/32 155.1.45.5 0 0 200i
*> 10.1.5.55/32 155.1.45.5 0 0 200?

 

第二步:验证属性

  1.as-set 使得汇总路由包含明细的AS-PATH,避免路由回馈

  2.detail-suppressed 过滤所有的明细路由,此时在聚合设备上还可以看到明细,但是在其他设备上(当然不包括源设备)就看不到明细了

  3.attribute-policy 修改聚合之后的聚合路由的属性(但是有的地方不让改,比如说AS-PATH)

  4.suppress-policy 抑制指定明细。当suppress-policy和detail-suppressed同时存在时,仅执行suppress-policy

  5.origin-policy 使仅利用特定的某几条明细来生成聚合路由

 

1.as-set

在AR4上汇总路由时携带AS-SET属性,此时携带了明细的AS-PATH。因为汇总路由是最优的,所以还是会发往AR5,但是因为AR5的EBGP防环机制:不接收AS-PATH包含本AS号的路由,所以不会被AR5接收

[AR4-bgp]aggregate 10.1.5.0 24 as-set 

[AR4]dis bgp routing-table peer 155.1.45.5 advertised-routes

BGP Local router ID is 155.1.45.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 10.1.1.1/32 155.1.45.4 0 100 200i
*> 10.1.5.0/24 155.1.45.4 0 100 200?

[AR5]dis bgp routing-table

*> 10.1.5.5/32 0.0.0.0 0 0 i
*> 10.1.5.55/32 0.0.0.0 0 0 ?

如果做聚合的多个明细来自不同AS,汇总路由的AS-PATH会包含所有明细的所有AS-PATH(手工增加AS-PATH的时候为了避免你瞎编的AS号后面通信的时候真的有,从而影响通信,建议直接加源AS号)

[AR5]route-policy SET-PATH permit node 10
[AR5-route-policy]apply as-path 200 200 200 additive
[AR5-bgp]network 10.1.5.5 32 route-policy SET-PATH

[AR4]dis bgp routing-table

BGP Local router ID is 155.1.45.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: 4
Network NextHop MED LocPrf PrefVal Path/Ogn

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 200 {200 200 200}?
*> 10.1.5.5/32 155.1.45.5 0 0 200 200 200 200i
*> 10.1.5.55/32 155.1.45.5 0 0 200?
[AR4]

 

 

2.detail-suppressed

利用detail-suppressed参数,抑制所有明细路由

未配置这个参数之前:

[AR2]dis bgp routing-table

*> 10.1.1.1/32 150.1.1.1 0 0 200i
*>i 10.1.5.0/24 9.9.9.10 100 0 200 {200 200 200}?
*>i 10.1.5.5/32 9.9.9.10 0 100 0 200 200 200 200i
*>i 10.1.5.55/32 9.9.9.10 0 100 0 200?

配置了这个参数之后:

[AR4-bgp]aggregate 10.1.5.0 24 as-set detail-suppressed

[AR4]dis bgp routing-table

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 200 {200 200 200}?
s> 10.1.5.5/32 155.1.45.5 0 0 200 200 200 200i     //S代表抑制,不会传递
s> 10.1.5.55/32 155.1.45.5 0 0 200?

[AR4]dis bgp routing-table peer 9.9.9.9 advertised-routes

*> 10.1.5.0/24 9.9.9.10 100 0 200 {200 200 200}?

[AR2]dis bgp routing-table

*> 10.1.1.1/32 150.1.1.1 0 0 200i
*>i 10.1.5.0/24 9.9.9.10 100 0 200 {200 200 200}?

 

 

3.attribute-policy

利用attribute-policy修改起源属性。

修改之前,根据路由聚合规则,只要有一个明细路由时import-route进来的,汇总路由的属性就会和这个明细一样是?(incomplete)

[AR4]dis bgp routing-table

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 200 {200 200 200}?
s> 10.1.5.5/32 155.1.45.5 0 0 200 200 200 200i
s> 10.1.5.55/32 155.1.45.5 0 0 200?

修改之后:

[AR4-bgp]aggregate 10.1.5.0 255.255.255.0 as-set detail-suppressed attribute-policy SET-ORI
Warning: SET-ORI used as BGP attribute-policy, apply as-path is not supported.                               //不支持修改汇总路由的AS-PATH
[AR4]route-policy SET-ORI permit n 10
Info: New Sequence of this List.
[AR4-route-policy]apply origin igp

[AR4]dis bgp routing-table

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 200 {200 200 200}i
s> 10.1.5.5/32 155.1.45.5 0 0 200 200 200 200i
s> 10.1.5.55/32 155.1.45.5 0 0 200?

 

 

4.suppress-policy

实用场景:

BGP 路由过虑 bgp路由过滤_路由表_04

 

 BGP聚合默认只走一条线,只有当这条线断了,才会走另一条线,为了把两条线都用上,两条线都漏出部分不同的明细下来,使得下面的AS200里面的网络设备根据掩码最长匹配原则分别从两条线上行

利用汇总路由抑制10.1.5.5/32的明细路由

[AR4-bgp]aggregate 10.1.5.0 255.255.255.0 as-set detail-suppressed suppress-policy SET-SUP
[AR4]route-policy SET-SUP permit node 10
Info: New Sequence of this List.
[AR4-route-policy]if
[AR4-route-policy]if-match ip-prefix NET5
[AR4]ip ip-prefix NET5 permit 10.1.5.5 32

[AR4]dis bgp routing-table peer 9.9.9.9 advertised-routes

*> 10.1.5.0/24 9.9.9.10 100 0 200 {200 200 200}?
*> 10.1.5.55/32 9.9.9.10 0 100 0 200?

 

 

5.origin-policy

利用origin-policy属性,仅使用10.1.5.5来创建汇总路由

[AR4-bgp]aggregate 10.1.5.0 255.255.255.0 as-set detail-suppressed origin-policy NET5

[AR4]route-policy NET5 permit node 10
[AR4-route-policy]if-match ip-prefix NET5

[AR4]dis bgp routing-table

*>i 10.1.1.1/32 9.9.9.9 0 100 0 200i
*> 10.1.5.0/24 127.0.0.1 0 200 200 200 200i
s> 10.1.5.5/32 155.1.45.5 0 0 200 200 200 200i
*> 10.1.5.55/32 155.1.45.5 0 0 200?

 

 

 

2.2自动聚合

  仅支持通过本地import方式引入的前缀

    1.聚合的路由必须存在本地路由表(路由来源:直连,静态,IGP)

    2.路由引入方式必须为:import-route

  聚合路由不保留明细路由属性

  主类方式聚合

 

实验步骤:

第一步:在AR1上尝试自动聚合通过network方式引入的10.1.1.1/32

[AR1-bgp]summary automatic
Info: Automatic summarization is valid only for the routes imported through the import-route command.  //提示仅支持通过import-route方式引入的路由

此时1.1并未被聚合

[AR1]dis bgp routing-table

*> 10.1.1.1/32 0.0.0.0 0 0 i
*> 10.1.5.55/32 150.1.2.2 0 100 200?

更改1.1的引入方式为Import-route之后

[AR1-bgp]undo network 10.1.1.1 255.255.255.255
[AR1]ip ip-prefix NET1 permit 10.1.1.1 32
[AR1]route-policy NET1 per n 10
[AR1-route-policy]if-match ip-prefix NET1
[AR1-bgp]import-route direct route-policy NET1

此时执行了自动的主类聚合

[AR1]dis bgp routing-table

*> 10.0.0.0 127.0.0.1 0 ?
s> 10.1.1.1/32 0.0.0.0 0 0 ?
*> 10.1.5.55/32 150.1.2.2 0 100 200?

 

第二步:更改明细路由属性,自动聚合的路由不会有任何变化

[AR1]route-policy NET1 permit node 10
[AR1-route-policy]if-match ip-prefix NET1
[AR1-route-policy]apply as-path 200 200 additive

[AR1-bgp]import-route direct route-policy NET1

[AR1]dis bgp routing-table

Network NextHop MED LocPrf PrefVal Path/Ogn

*> 10.0.0.0 127.0.0.1 0 ?
s> 10.1.1.1/32 0.0.0.0 0 0 200 200?
*> 10.1.5.55/32 150.1.2.2 0 100 200?

 

 

 

 

Ⅲ.BGP过滤-控制BGP路由的发布和接收

  3.1 ACL,ip-prefix

BGP是唯一一个可以直接利用前缀列表来实现过滤的协议

利用前缀列表实现AR1上仅能学习到明细路由

[AR2-bgp]peer 150.1.1.1 ip-prefix NET5 export 

[AR2]DIS IP ip-prefix
index: 10 permit 10.1.5.5/32
index: 20 permit 10.1.5.55/32

[AR2]DIS BGP routing-table peer 150.1.1.1 advertised-routes

*>i 10.1.5.55/32 150.1.2.2 0 100 200?

 

  3.2 filter-policy

现实环境中不推荐使用filter-policy来过滤BGP路由条目,因为他没有指定邻居,意味着是对所有邻居进行了过滤。

撤销掉之前的过滤限制,在AR5上破除EBGP防环机制,使得AR2,AR5上都有聚合的路由和明细路由

[AR2]dis bgp routing-table

*> 10.1.1.1/32 150.1.1.1 0 0 200 200 200?
*>i 10.1.5.0/24 9.9.9.10 100 0 200 {200 200 200}?
*>i 10.1.5.5/32 9.9.9.10 0 100 0 200 200 200 200i
*>i 10.1.5.55/32 9.9.9.10 0 100 0 200?

[AR5]dis bgp routing-table

*> 10.1.1.1/32 155.1.45.4 0 100 200 200 200?
*> 10.1.5.0/24 155.1.45.4 0 100 200 {200 200 200}?
*> 10.1.5.5/32 0.0.0.0 0 0 200 200 200i
*> 10.1.5.55/32 0.0.0.0 0 0 ?

利用filter-policy实现bgp网络中除了AR4,其他路由器都没有聚合路由10.1.5.0/24

[AR4]DIS IP ip-prefix
Prefix-list NET5
index: 10 permit 10.1.5.5/32
index: 20 permit 10.1.5.55/32

[AR4-bgp]filter-policy ip-prefix NET5 export 

[AR4]dis bgp routing-table peer 9.9.9.9 advertised-routes

*> 10.1.5.5/32 9.9.9.10 0 100 0 200 200 200 200i
*> 10.1.5.55/32 9.9.9.10 0 100 0 200?

[AR4]dis bgp routing-table peer 155.1.45.5 advertised-routes
[AR4]

 

  3.3 route-policy

删除前面的filter-policy,利用route-policy使得AR4只向AR2发送150.1.5.5/32的路由

[AR4-bgp]peer 9.9.9.9 route-policy SET-NET5 export

[AR4]route-policy SET-NET5 per n 10
[AR4-route-policy]if-match ip-prefix NET
[AR4]ip ip-prefix NET permit 10.1.5.5 32

[AR4]dis bgp routing-table peer 9.9.9.9 advertised-routes

*> 10.1.5.5/32 9.9.9.10 0 100 0 200 200 200 200i  

 

  3.4 ORF

适用场景:当客户与运营商对接BGP,想要只接收到部分路由。因为没有权限在运营商的对接设备上export设置,在自己的对接设备上import是可以限制路由,但是这些路由还是发了过来并占用了带宽。

解决方法:联系运营商开启ORF接收,我在自己的对接设备上做入方向策略过滤,并发送到运营商对接设备上,运营商就会自动生成出方向的策略

删除掉前面的过滤配置,AR1模拟客户,AR2模拟运营商,AR1只想接收10.1.5.5/32的路由

未配置前:

[AR1]dis bgp routing-table

*> 10.1.1.1/32 0.0.0.0 0 0 200 200?
*> 10.1.5.0/24 150.1.2.2 0 100 200 {200 200 200}?
*> 10.1.5.5/32 150.1.2.2 0 100 200 200 200 200i
*> 10.1.5.55/32 150.1.2.2 0 100 200?
[AR1]

配置后:

[AR1]ip ip-prefix NET5 permit 10.1.5.5 32

[AR1-bgp]peer 150.1.2.2 ip-prefix NET5 import 

[AR1-bgp]peer 150.1.2.2 capability-advertise orf ip-prefix send 

[AR2-bgp]peer 150.1.1.1 capability-advertise orf ip-prefix receive 

[AR2]dis bgp routing-table peer 150.1.1.1 advertised-routes

*>i 10.1.5.5/32 150.1.2.2 0 100 200 200 200 200i