示例:在 EX9200 交换机上启用 OpenFlow
OpenFlow 是一种开放标准,您可以通过在路径上为每个设备(包括安装了 OpenFlow 软件包的 EX9200 交换机)中创建、删除和修改流来控制网络中流量路径。此示例说明如何在 EX9200 交换机上配置 OpenFlow 支持。
要求
此示例使用以下硬件和软件组件:
运行 Junos OS 13.3 或更高版本的 EX9200 交换机。
交换机上安装了 OpenFlow 软件包,软件包版本与交换机上运行的 Junos OS 版本匹配。
交换机与 OpenFlow 控制器有 TCP 连接,该控制器需要访问交换机的数据平面。
交换机通过 me0 接口连接到管理网络,可从 OpenFlow 控制器 IP 地址访问。
概述和拓扑
在此示例中,您在 EX9200 交换机上配置对 OpenFlow 的支持。该交换机有三个接口,用于处理 OpenFlow 流量:ge-1/0/0.0、ge-1/1/0.0 和 xe-0/0/0.0。
EX9200 交换机需要用于虚拟交换机的单独路由实例。此路由实例将实验性 OpenFlow 流量与正常网络流量隔离开来。在此示例中,通过使用层级的实例类型,OF-ri
为虚拟交换机配置路由实例virtual-switch
[edit routing-instances]
。路由实例OF-ri
包括参与 OpenFlow 的所有逻辑接口。
虚拟交换机 OFswitch1
通过 IP 地址为 198.51.100.174 的 TCP 连接连接到 OpenFlow 控制器。虚拟交换机配置必须包含参与 OpenFlow 的所有逻辑接口,并且 OpenFlow 流量只能进出这些接口。
流条目包含一个匹配条件,根据该条件比较进入 OpenFlow 接口的数据包,以及应用于匹配该条件的数据包的操作。每个 OpenFlow 接口都可以有一个或多个流条目。 default-action
OpenFlow 配置中的语句表示交换机对没有匹配流条目的数据包所应用的操作。如果未显式配置 default-action
语句,则默认操作为 packet-in
,表示没有匹配流条目的数据包将发送到 OpenFlow 控制器进行处理。在此示例中,您将将 packet-in
配置为没有匹配流条目的数据包的默认操作。
在此示例中,您还可以配置 OpenFlow 追踪选项。使用语句配置 flag all
追踪选项时,将捕获并记录所有 OpenFlow 事件。在此示例中,未为日志文件配置特定文件名。因此,OpenFlow 事件会记录在 /var/log/ofd 的默认 OpenFlow 日志文件中。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,将命令复制并粘贴到层级的 [edit]
CLI 中,然后从配置模式进入 commit
。
set interfaces ge-1/0/0 unit 0 family ethernet-switching set interfaces ge-1/1/0 unit 0 family ethernet-switching set interfaces xe-0/0/0 unit 0 family ethernet-switching set routing-instances OF-ri instance-type virtual-switch set routing-instances OF-ri interface ge-1/0/0.0 set routing-instances OF-ri interface ge-1/1/0.0 set routing-instances OF-ri interface xe-0/0/0.0 set routing-instances OF-ri vlans of-bridge vlan-id none set protocols openflow switch OFswitch1 controller address 198.51.100.174 set protocols openflow switch OFswitch1 controller protocol tcp port 6633 set protocols openflow switch OFswitch1 interfaces ge-1/0/0.0 set protocols openflow switch OFswitch1 interfaces ge-1/1/0.0 set protocols openflow switch OFswitch1 interfaces xe-0/0/0.0 set protocols openflow switch OFswitch1 default-action packet-in set protocols openflow traceoptions flag all
程序
逐步过程
要配置对 OpenFlow 的支持:
将 OpenFlow 接口配置为第 2 层接口:
[edit interfaces] user@switch# set ge-1/0/0 unit 0 family ethernet-switching user@switch# set ge-1/1/0 unit 0 family ethernet-switching user@switch# set xe-0/0/0 unit 0 family ethernet-switching
配置虚拟交换机路由实例:
[edit routing-instances] user@switch# set OF-ri instance-type virtual-switch user@switch# set OF-ri interface ge-1/0/0.0 user@switch# set OF-ri interface ge-1/1/0.0 user@switch# set OF-ri interface xe-0/0/0.0 user@switch# set OF-ri vlans of-bridge vlan-id none
配置 OpenFlow 控制器 IP 地址和连接协议:
[edit protocols openflow switch OFswitch1] user@switch# set controller address 198.51.100.174 user@switch# set controller protocol tcp port 6633
在此虚拟交换机实例下,配置参与 OpenFlow 的逻辑接口:
[edit protocols openflow switch OFswitch1] user@switch# set interfaces ge-1/0/0.0 user@switch# set interfaces ge-1/1/0.0 user@switch# set interfaces xe-0/0/0.0
为没有匹配流条目的数据包配置默认操作:
[edit protocols openflow switch OFswitch1] user@switch# set default-action packet-in
配置 OpenFlow 追踪选项:
[edit protocols openflow] user@switch# set traceoptions flag all
提交配置:
[edit] user@switch# commit
结果
在操作模式下,输入 、 show configuration protocols openflow
和show configuration routing-instances
命令,show configuration interfaces
显示配置结果。如果输出未显示指定的配置,请重复此示例中的说明,以更正配置。
user@switch> show configuration interfaces ge-1/0/0 { unit 0 { family ethernet-switching; } } ge-1/1/0 { unit 0 { family ethernet-switching; } } xe-0/0/0 { unit 0 { family ethernet-switching; } }
user@switch> show configuration protocols openflow switch OFswitch1 { default-action { packet-in; } interfaces { ge-1/0/0.0; ge-1/1/0.0; xe-0/0/0.0; } controller { address 198.51.100.174; protocol tcp { port 6633; } } traceoptions { flag all; }
user@switch> show configuration routing-instances OF-ri { instance-type virtual-switch; interface ge-1/0/0.0; interface ge-1/1/0.0; interface xe-0/0/0.0; vlans { of-bridge { vlan-id none; } } }
验证
确认配置工作正常。
验证 OpenFlow 控制器连接
目的
验证 OpenFlow 控制器连接是否已开启。
行动
发出 show openflow controller
操作模式命令以验证控制器连接状态是否为 up
。由于虚拟交换机配置只有一个控制器,因此在您提交配置后,虚拟交换机会自动启动与控制器的连接。
user@switch> show openflow controller Openflowd controller information: Controller socket: 11 Controller IP address: 198.51.100.174 Controller protocol: tcp Controller port: 6633 Controller connection state: up Number of connection attempt: 5 Controller role: equal
意义
除了有关控制器 up
的其他信息外,输出还显示 OpenFlow 控制器的连接状态。
验证 OpenFlow 接口
目的
验证 OpenFlow 接口是否已开启。
行动
发出 show openflow interfaces
操作模式命令,并验证每个 OpenFlow 接口的状态是否为 Up
。
user@switch> show openflow interfaces Switch name: OFswitch1 Interface Name: ge-1/0/0.0 Interface port number: 41507 Interface Hardware Address: 00:00:5E:00:53:b1 Interface speed: 1Gb Full-duplex Interface Auto-Negotiation: Disabled Interface media type: Fiber Interface state: Up Switch name: OFswitch1 Interface Name: ge-1/1/0.0 Interface port number: 44538 Interface Hardware Address: 00:00:5E:00:53:b2 Interface speed: 1Gb Full-duplex Interface Auto-Negotiation: Disabled Interface media type: Fiber Interface state: Up Switch name: OFswitch1 Interface Name: xe-0/0/0.0 Interface port number: 45549 Interface Hardware Address: 00:00:5E:00:53:b3 Interface speed: 10Gb Full-duplex Interface Auto-Negotiation: Disabled Interface media type: Fiber Interface state: Up
意义
除了有关接口 Up
的其他信息外,输出还显示每个 OpenFlow 接口的状态。