2022-07-29 网工进阶(二十二)BGP-其他特性(路由过滤、团体属性、认证、AS欺骗、对等体组、子路由器、路由最大接收数量)

BGP路由过滤

BGP路由有2种过滤方式:1、使用filter-policy工具过滤。 2、针对对等体使用ip-prefix过滤。

这2种方法都有对2种方向的过滤,export(出方向)、import(入方向)。

1 使用filter-policy工具过滤

[R1-acl-basic-2000]rule 5 deny source 1.1.1.1 0
[R1-acl-basic-2000]rule 10 permit

[R1-bgp]filter-policy 2000 ?
  export  Filter outgoing routing updates
  import  Filter incoming routing updates

2 针对对等体使用ip-prefix过滤

[R1]ip ip-prefix 1 index 10 deny 1.1.1.1 32
[R1]ip ip-prefix 2 index 20 permit 0.0.0.0 0 less-equal 32

[R1-bgp]peer 2.2.2.2 ip-prefix 1 ?
  export  Specify export policy
  import  Specify import policy

团体属性

团体属性属于可选过度属性。

BGP的团体属性是指标识具有相同特征的BGP路由,我们可以理解为具有相同标签的BGP路由,这个标签就是它的团体属性。

作用:可以通过相同的团体属性路由来控制路由的传播范围

团体属性分为两种:公认的团体属性、私有的团体属性。

公认的团体属性

公认的团体属性有四种参数可以控制路由的传递范围。

[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

1.internet 表示可以向任何对等体发送匹配的路由。

2.no-export-subconfed 指定不向自治系统外部通告路由。如果使用了联盟,则不会向联盟中的其他子自治系统通告路由。

3.no-advertise 指定不通告给其他对等体。

4.no-export 指定不向自治系统外部通告路由。如果使用了联盟,则不向联盟外部通告路由,但会通告给联盟中的其他子自治系统。

internet

配置举例

//创建匹配规则
[R7-acl-basic-2000]rule 5 permit source 77.77.77.77 0


//配置匹配后动作
[R7]route-policy 1 permit node 10
[R7-route-policy]if-match acl 2000
[R7-route-policy]apply community internet 


//引入匹配规则
[R7-bgp]network 77.77.77.77 32 route-policy 1 

//通告团体属性给指定的对等体
[R7-bgp]peer 5.5.5.5 advertise-community

查看结果

<R5>dis bgp routing-table 77.77.77.77

 BGP local router ID : 5.5.5.5
 Local AS number : 200
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 77.77.77.77/32:
 From: 7.7.7.7 (7.7.7.7)
 Route Duration: 00h00m08s  
 Relay IP Nexthop: 20.2.0.7
 Relay IP Out-Interface: GigabitEthernet0/0/1
 Original nexthop: 7.7.7.7
 Qos information : 0x0
 Community:internet
 AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 255, IGP cost 1
 Advertised to such 1 peers:
    1.1.1.1

分析:Community:internet条目代表生效

no-export

配置举例

//创建匹配规则
[R7-acl-basic-2000]rule 5 permit source 77.77.77.77 0


//配置匹配后动作
[R7]route-policy 1 permit node 10
[R7-route-policy]if-match acl 2000
[R7-route-policy]apply community no-export


//引入匹配规则
[R7-bgp]network 77.77.77.77 32 route-policy 1 

//通告团体属性给指定的对等体
[R7-bgp]peer 5.5.5.5 advertise-community
[R7-bgp]peer 6.6.6.6 advertise-community

查看结果

<R5>dis bgp routing-table 77.77.77.77

 BGP local router ID : 5.5.5.5
 Local AS number : 200
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 77.77.77.77/32:
 From: 7.7.7.7 (7.7.7.7)
 Route Duration: 00h00m21s  
 Relay IP Nexthop: 20.2.0.7
 Relay IP Out-Interface: GigabitEthernet0/0/1
 Original nexthop: 7.7.7.7
 Qos information : 0x0
 Community:no-export
 AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 255, IGP cost 1
 Not advertised to any peer yet

分析: Community:no-export条目代表生效

<R1>display bgp routing-table 77.77.77.77
Info: The network does not exist.

分析:在另一个AS的路由上77.77.77.77这条路由已经不显示了

no-advertise

配置举例

//创建匹配规则
[R7-acl-basic-2000]rule 5 permit source 77.77.77.77 0


//配置匹配后动作
[R7]route-policy 1 permit node 10
[R7-route-policy]if-match acl 2000
[R7-route-policy]apply community no-advertise


//引入匹配规则
[R7-bgp]network 77.77.77.77 32 route-policy 1 

查看结果

[R7]dis bgp routing-table 77.77.77.77

 BGP local router ID : 7.7.7.7
 Local AS number : 200
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 77.77.77.77/32:
 Network route. 
 From: 0.0.0.0 (0.0.0.0)
 Route Duration: 00h01m01s  
 Direct Out-interface: InLoopBack0
 Original nexthop: 127.0.0.1
 Qos information : 0x0
 Community:no-advertise
 AS-path Nil, origin igp, MED 0, pref-val 0, valid, local, best, select, pre 0
 Not advertised to any peer yet

分析:Community:no-advertise表示生效

<R5>display bgp routing-table 77.77.77.77
Info: The network does not exist.

分析:在指定的对等体上77.77.77.77这条路由已经不存在了

私有的团体属性

[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

STRING<3-11>:自定义的私有团体属性,通常为AS号:自定义号。可以使用ip community-filter工具进行抓取后过滤。

配置举例

//创建匹配规则
[R7-acl-basic-2000]rule 5 permit source 77.77.77.77 0


//配置匹配后动作
[R7]route-policy 1 permit node 10
[R7-route-policy]if-match acl 2000
[R7-route-policy]apply community 200:70


//引入匹配规则
[R7-bgp]network 77.77.77.77 32 route-policy 1 

//通告团体属性给指定的对等体
[R7-bgp]peer 5.5.5.5 advertise-community

查看结果

<R5>display bgp routing-table 77.77.77.77

 BGP local router ID : 5.5.5.5
 Local AS number : 200
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 77.77.77.77/32:
 From: 7.7.7.7 (7.7.7.7)
 Route Duration: 00h00m31s  
 Relay IP Nexthop: 20.2.0.7
 Relay IP Out-Interface: GigabitEthernet0/0/1
 Original nexthop: 7.7.7.7
 Qos information : 0x0
 Community:<200:70>
 AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, bes
t, select, active, pre 255, IGP cost 1
 Advertised to such 1 peers:
    1.1.1.1

分析:Community:<200:70>表示成功传递私有的团体属性。

使用ip community-filter工具进行抓取后过滤

配置举例

//对指定的团体属性进行抓取
[R5]ip community-filter 1 permit 200:70


//配置过滤动作
[R5]route-policy 1 deny node 10
[R5-route-policy]if-match community-filter 1
[R5]route-policy 1 permit node 20


//针对对等体入方向进行过滤
[R5-bgp]peer 7.7.7.7 route-policy 1 import 

查看结果

[R5]dis bgp routing-table 77.77.77.77
Info: The network does not exist.

认证

BGP使用TCP作为传输层协议,为提高BGP的安全性,可以在建立TCP连接时进行MD5认证。BGP的MD5认证只是为TCP连接设置MD5认证密码,由TCP完成认证。

相关命令

peer password命令用来配置BGP对等体在建立TCP连接时对BGP消息进行MD5认证

[R1-bgp]peer 3.3.3.3 password cipher 123

AS欺骗

该命令常用于运营商修改网络部署的场景。例如当运营商A收购了运营商B时,由于两者位于不同的AS,因此需要把运营商B的AS合并到运营商A的AS中,即将原运营商B的AS号修改为运营商A的AS号。但是在网络合并过程中,原运营商B位于其他AS的BGP对等体可能不期望或者不便立即修改本地的BGP配置,此时就会造成与这些对等体的连接中断。

为了保证网络合并的顺利进行,可以在原运营商B的ASBR上执行peer fake-as命令,将原运营商B的AS号设置为合并后的运营商A的伪AS号,使原运营商B的BGP对等体能够继续使用伪AS号建立连接。

PS:

对于同一对等体或对等体组,重新配置该命令会覆盖原有的配置信息。

peer fake-as命令只对EBGP对等体有效。

在取消了对等体的4字节AS号能力后,给对等体配置一个4字节的伪AS号可能会导致会话建立失败。

相关命令

peer fake-as命令用来配置本端采用伪AS号与指定对等体建立连接。

[R1-bgp]peer 5.5.5.5 fake-as 150

对等体组

对等体组(Peer Group)是一些具有某些相同配置的对等体的集合。当一个对等体加入对等体组中时,此对等体将获得与所在对等体组相同的配置。对等体组中的对等体可以继承对等体组的配置,当对等体组的配置改变时,组内成员的配置也相应改变。

在大型BGP网络中,对等体的数量会很多,其中很多对等体具有相同的配置,在配置时会重复使用一些命令,利用对等体组可以简化配置。当用户想对几个对等体进行相同配置的时候,可以先创建一个对等体组并对其进行相应的配置,然后将对等体再加入到该组中,这样,组内的所有对等体都具有了该组的配置。
 

PS

group命令是累增式命令。

缺省为创建IBGP对等体组。

若BGP对等体组内的对等体在某属性配置上与对等体组不一致,则当undo对等体上该属性配置时,对等体会从对等体组上继承该属性配置。

删除对等体组会导致该组内没有配置AS号的对等体中断连接,建议先删除掉对等体组里没有配置AS号的对等体或给这些对等体先配置上AS号,然后再删除对等体组。
 

相关命令

加入对等体组ceshi并且指定IBGP或者EBGP

[R1-bgp]group ceshi ?
  external  Create an external group
  internal  Create an internal group
  <cr>      Please press ENTER to execute command 

对对等体组测试进行配置

[R1-bgp]peer ceshi connect-interface LoopBack 0

子路由器

在OSPF中有个子路由器的配置可以和BGP产生联动,当一台路由重启时,它的IGP会先开始工作,之后EGP才会开始工作,会造成短时间的路由黑洞。如果配置了子路由器,IGP就会等待EGP同时工作

可以应用于割接场景下使用。

相关命令

仅配置stub-router命令,未选择on-startup参数,则表示该路由器始终保持为Stub设备,即所有来自这个路由器的路由条目Cost值均设为65535。

[R1-ospf-1] stub-router

配置stub-router on-startup命令,则表示该路由器仅在重启或者主备倒换时保持为Stub设备,保持时间由interval参数决定。此时若未配置interval参数,则使用interval的缺省值500秒;如果配置了interval参数,则使用interval参数定义的值。

[R1-ospf-1] stub-router on-startup

路由最大接收数量

BGP路由表路由数量通常都很大,为了防止从对等体接收到大量路由而导致消耗过多系统资源,可以使用该命令来为一个BGP路由器设置允许从其对等体收到的最大路由数量。这样就在分配列表、过滤列表和路由映射的基础上,对接收对等体发送的路由又增加了一个控制机制。

相关命令

peer route-limit命令用来设置允许从对等体收到的路由数量

[R1-bgp]peer 3.3.3.3 route-limit ?
  INTEGER<1-80000>  Route limit value

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鹅一只

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值