BGP Flowspec 的快速解释
BGP Flowspec 允许您在 BGP UPDATE 消息中发送条件和操作。
条件
条件在 RFC4760 中定义的 MP_REACH_NLRI 或 MP_UNREACH_NLRI 中进行了描述。
使用的 AFI 和 SAFI 如下。AFI:1SAFI:133
http://www.iana.org/assignments/safi-namespace/safi-namespace.xhtml如果不使用 NextHop,则长度应为 0。
+---------------------------------------------------------+
| Address Family Identifier (2 octets) |
+---------------------------------------------------------+
| Subsequent Address Family Identifier (1 octet) |
+---------------------------------------------------------+
| Length of Next Hop Network Address (1 octet) |
+---------------------------------------------------------+
| Network Address of Next Hop (variable) |
+---------------------------------------------------------+
| Reserved (1 octet) |
+---------------------------------------------------------+
| Network Layer Reachability Information (variable) |
+---------------------------------------------------------+
+---------------------------------------------------------+
| Address Family Identifier (2 octets) |
+---------------------------------------------------------+
| Subsequent Address Family Identifier (1 octet) |
+---------------------------------------------------------+
| Withdrawn Routes (variable) |
+---------------------------------------------------------+
可指定为条件的内容如下。
- 类型 1 - 目标前缀
- 类型 2 - 源前缀
- 类型 3 - IP 协议
- 类型 4 - 端口
- 类型 5 - 目标端口
- 类型 6 - 源端口
- 类型 7 - ICMP 类型
- 类型 8 - ICMP 代码
- 类型 9 - TCP 标志
- 类型 10 - 数据包长度
- 类型 11 - DSCP(Diffserv 代码点)
- 类型 12 - 碎片
* Type3是IP包中协议类型的值,对于Type3-Type12,也可以使用不等号等比较运算符。
也可以使用多种类型创建条件,在这种情况下,原则上它将是 AND 评估。
如果您创建多个条件,则一个流量可能会匹配多个条件。在这种情况下,优先匹配号码类型较年轻的条件。如果 Type 具有相同的优先级,则按照以下规则给予优先级。Type1 和 Type2 的最小前缀匹配,其他类型的最长字符串匹配。
行动
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type high | Type low(*) | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Value |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
类型 0x8006 --traffic-rate以 4 字节浮点数指定以 Bps 为单位的流量速率。如果指定为 0,则表示流量被丢弃。
-
类型 0x8007 -- traffic-action终端位和样本位。如果设置了终端位,则应用随后的操作,否则操作到此结束。如果设置了采样位,将执行采样和记录。
-
键入 0x8008 --redirect 流量重定向到 VRF。您可以在一个列表中指定多个 VRF。但是,它不能重定向到多个 VRF。它的处理方式与 RFC4360 中的 RT 相同。
-
类型 0x8000 --traffic-markingIP 数据包的 DSCP 标记(或重新标记)
-
参考文献
RFC5575 Dissemination of Flow Specification Rules https://tools.ietf.org/html/rfc5575
RFC4760 Multiprotocol Extensions for BGP-4 https://tools.ietf.org/html/rfc4760
RFC4360 BGP Extended Communities Attribute https://tools.ietf.org/html/rfc4360https://milestone-of-se.nesuke.com/nw-advanced/mpls-vpn/detail-of-mp-bgp/http://www.hogetan.net/translate/bgpflowspec-1/bgpflowspec.html