BGP的路由过滤和社团属性

文章详细介绍了BGP协议中的路由过滤方法,包括使用前缀列表、路由策略和过滤列表进行过滤,并阐述了BGP的社团属性及其作用,如no-advertise、no-export等。此外,还提供了如何通过route-policy设置特定社团属性以及如何利用这些属性控制路由传播的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

一、BGP的路由过滤

二、BGP的社团属性(打标记)


一、BGP的路由过滤

1.使用前缀列表进行过滤

配置命令: [r1]ip ip-prefix aa deny 192.168.1.0 24

[r1]ip ip-prefix aa permit 0.0.0.0 0 less-equal 32

[r1-bgp]peer 12.0.0.2 ip-prefix aa export

2.使用路由策略进行过滤

配置命令:[r2]ip ip-prefix aa permit 192.168.2.0 24

[r2]route-policy aa deny node 10

Info: New Sequence of this List.

[r2-route-policy]if-match ip-prefix aa

[r2-route-policy]q

[r2]route-policy aa permit node 20

Info: New Sequence of this List.

[r2-route-policy]q

[r2-bgp]peer 12.0.0.1 route-policy aa import

3.使用filter-policy(过滤列表)进行过滤

配置命令:[r3-acl-basic-2000]rule deny source 192.168.3.0 0注意使用过滤列表时,抓取流量的列表必须使用拒绝动作

[r3-acl-basic-2000]rule permit source any注意:对于不需要过滤的流量,一定要进行放通

[r3-bgp]peer 13.0.0.1 filter-policy 2000 import

二、BGP的社团属性(打标记)

社团属性—由32位二进制构成(四个字节)—使用十进制表示或AS:NN—一条路由条目可以同时打多个社团属性

公有社团属性:①0X00000000(十六进制)—0—“internet”—所有的BGP路由默认都打上了名称为“internet”的社团属性(补充:0b—二进制、0o—八进制)

              ②0XFFFFFF02—“no-advertise”—如果BGP路由打上该社团属性,则代表不允许通告给其他的BGP对等体

              ③0XFFFFFF01—“no-export”—如果BGP路由打上该社团属性,则将不允许通告给自己的EBGP对等体(不包括联邦的EBGP对等体)

              ④0XFFFFFF03—“no-export-subconfed”—如果BGP路由打上该社团属性,则将不允许通告给自己的EBGP对等体(包括联邦的EBGP对等体)

[r1]route-policy com permit node 10

Info: New Sequence of this List.

[r1-route-policy]apply community ?

INTEGER<0-4294967295> Specify community number

STRING<3-11> Specify aa<0-65535>:nn<0-65535>

internet Internet(well-known community attributes)

no-advertise Do not advertise to any peer (well-known community

attributes)

no-export Do not export to external peers(well-known community

attributes)

no-export-subconfed Do not send outside a sub-confederation(well-known

community attributes)

none No community attribute

[r1-route-policy]apply community no-advertise

[r1-route-policy]q

[r1-bgp]peer 12.0.0.2 route-policy com export

[r1-bgp]peer 12.0.0.2 advertise-community开启社团属性的传递功能

需求AS1中分别创建

172.16.0.0/24,172.16.1.0/24,172.16.2.0/24,172.16.3.0/24

0.0和1.0带上1:11的社团属性,2.0和3.0带上1:22的社团属性

要求1:11社团的路由不传递1:22的路由no_export

做社团属性的策略

[r1]route-policy com1 permit node 10

Info: New Sequence of this List.

[r1-route-policy]apply community 1:11

[r1-route-policy]q

[r1]route-policy com2 permit node 10

Info: New Sequence of this List.

[r1-route-policy]apply community 1:22

发布路由

network 172.16.0.0 255.255.255.0 route-policy com1

network 172.16.1.0 255.255.255.0 route-policy com1

network 172.16.2.0 255.255.255.0 route-policy com2

network 172.16.3.0 255.255.255.0 route-policy com2

依靠社团属性抓取流量community-filter

[r1]ip community-filter 1 permit 1:11

[r1]ip community-filter 2 permit 1:22

做路由策略

[r1]route-policy aaa deny node 10

Info: New Sequence of this List.

[r1-route-policy]if-match community-filter 1

[r1-route-policy]q

[r1]route-policy aaa permit node 20

Info: New Sequence of this List.

[r1-route-policy]if-match community-filter 2

[r1-route-policy]apply community no-export ?

INTEGER<0-4294967295> Specify community number

STRING<3-11> Specify aa<0-65535>:nn<0-65535>

additive Add to the existing community

internet Internet(well-known community attributes)

no-advertise Do not advertise to any peer (well-known community

attributes)

no-export Do not export to external peers(well-known community

attributes)

no-export-subconfed Do not send outside a sub-confederation(well-known

community attributes)

<cr> Please press ENTER to execute command

[r1-route-policy]apply community no-export additive

[r1-route-policy]q

[r1]route-policy aaa permit node 30

[r1-route-policy]q

调用

[r1-bgp]peer 12.0.0.2 route-policy aaa export

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值