交换机OpenFlow典型配置举例.docx
《交换机OpenFlow典型配置举例.docx》由会员分享,可在线阅读,更多相关《交换机OpenFlow典型配置举例.docx(48页珍藏版)》请在冰豆网上搜索。
交换机OpenFlow典型配置举例
H3CS5130-EIOpenFlow典型配置举例
1简介
本文档介绍了OpenFlow的配置举例。
OpenFlow允许控制器直接访问和操作网络设备的转发平面,将控制平面和数据平面分离。
交换机依据控制器下发的流表(FlowTable)对报文进行匹配和转发,在同一个流表中按照流表项的优先级大小进行匹配。
一个OpenFlow交换机可以包含一个或者多个流表。
2配置前提
本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。
如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。
本文档中所有配置举例中使用的控制器均为H3CVCF(VirtualConvergedFramework,虚拟应用融合架构)控制器。
本文假设您已了解OpenFlow特性。
3OpenFlow基本功能配置举例(控制器动态下发流表项)
3.1组网需求
如图1所示,HostA和HostC属于VLAN4092;HostB和HostD属于VLAN4094;它们之间通过SwitchA和SwtichB进行连接。
现要求通过对SwitchA和SwitchB进行OpenFlow配置,使VLAN
4092和VLAN4094内的主机基于控制器下发的流表项进行通信,即要求交换机对VLAN4092和
VLAN4094内的数据进行OpenFlow转发。
图3-1OpenFlow基本功能配置举例组网图
Controller192.168.2.225/24
HostB20.1.1.1/24
HostD20.1.1.2/24
3.2配置思路
∙为了使控制器可以通过LLDP学习OpenFlow网络拓扑,设备上必须全局使能LLDP功能。
∙为了使OpenFlow实例与控制器建立连接,需要配置交换机与控制器之间路由可达,本例中以VLAN接口1作为与控制器通信的接口。
∙为了保持交换机与控制器之间连接的可靠性,需要使用TCP/SSL建立连接。
本例中采用TCP方式建立交换机与控制器之间的连接。
如果需要更高的连接可靠性,可以选择使用SSL建立连接。
∙为了使连接主机的Access类型的端口成为OpenFlow端口,配置映射VLAN4092、VLAN4094
时,需要选择Loosen模式。
3.3使用版本
本举例是在S5130EI_E-CMW710-R3106版本上进行配置和验证的。
3.4配置步骤
3.4.1SwitchA的配置
#配置VLAN。
system-view[SwitchA]vlan4092[SwitchA-vlan4092]quit[SwitchA]vlan4094[SwitchA-vlan4094]quit
#配置SwitchA上的接口GigabitEthernet3/0/1、GigabitEthernet3/0/2和GigabitEthernet3/0/3。
[SwitchA]interfaceGigabitEthernet3/0/1
[SwitchA-GigabitEthernet3/0/1]portaccessvlan4092[SwitchA-GigabitEthernet3/0/1]quit[SwitchA]interfaceGigabitEthernet3/0/2
[SwitchA-GigabitEthernet3/0/2]portaccessvlan4094[SwitchA-GigabitEthernet3/0/2]quit[SwitchA]interfaceGigabitEthernet3/0/3
[SwitchA-GigabitEthernet3/0/3]portlink-typetrunk
[SwitchA-GigabitEthernet3/0/3]porttrunkpermitvlan40924094[SwitchA-GigabitEthernet3/0/3]quit
#全局使能LLDP功能。
[SwitchA]lldpglobalenable
#配置VLAN接口1用于和控制器建立连接。
[SwitchA]interfaceVlan-interface1
[SwitchA-Vlan-interface1]ipaddress192.168.2.125255.255.255.0[SwitchA-Vlan-interface1]quit
#创建OpenFlow实例1并映射VLAN4092和VLAN4094,同时选择映射模式为Loosen模式。
[SwitchA]openflowinstance1
[SwitchA-of-inst-1]classificationvlan4092mask4093loosen
#配置控制器0的IP地址并激活实例。
[SwitchA-of-inst-1]controller0addressip192.168.2.225[SwitchA-of-inst-1]activeinstance
[SwitchA-of-inst-1]quit
3.4.2SwitchB的配置
#配置VLAN。
system-view[SwitchB]vlan4092[SwitchB-vlan4092]quit[SwitchB]vlan4094[SwitchB-vlan4094]quit
#配置SwitchB上的接口GigabitEthernet3/0/1、GigabitEthernet3/0/2和GigabitEthernet3/0/3。
[SwitchB]interfaceGigabitEthernet3/0/1
[SwitchB-GigabitEthernet3/0/1]portaccessvlan4092[SwitchB-GigabitEthernet3/0/1]quit[SwitchB]interfaceGigabitEthernet3/0/2
[SwitchB-GigabitEthernet3/0/2]portaccessvlan4094[SwitchB-GigabitEthernet3/0/2]quit[SwitchB]interfaceGigabitEthernet3/0/3
[SwitchB-GigabitEthernet3/0/3]portlink-typetrunk
[SwitchB-GigabitEthernet3/0/3]porttrunkpermitvlan40924094[SwitchB-GigabitEthernet3/0/3]quit
#全局使能LLDP功能。
[SwitchB]lldpglobalenable
#配置VLAN接口1用于和控制器建立连接。
[SwitchB]interfaceVlan-interface1
[SwitchB-Vlan-interface1]ipaddress192.168.2.126255.255.255.0[SwitchB-Vlan-interface1]quit
#创建OpenFlow实例1并映射VLAN4092和VLAN4094,同时选择映射模式为Loosen模式。
[SwitchB]openflowinstance1
[SwitchB-of-inst-1]classificationvlan4092mask4093loosen
#配置控制器0的IP地址并激活实例。
[SwitchB-of-inst-1]controller0addressip192.168.2.225[SwitchB-of-inst-1]activeinstance
[SwitchB-of-inst-1]quit
3.5验证配置
(1)在SwitchA上进行验证
#查看SwitchA上OpenFlow实例1的信息。
[SwitchA]displayopenflowinstance1Instance1information:
Configurationinformation:
Description:
--
Activestatus:
activeInactiveconfiguration:
none
Activeconfiguration:
ClassificationVLAN,loosenmode,totalVLANs
(2)
4092,4094
In-bandmanagementVLAN,totalVLANs(0)emptyVLAN
Connectmode:
multiple
MACaddresslearning:
EnabledFlowtable:
TableID(type):
0(Extensibility),count:
1Flow-entrymax-limit:
8192
DatapathID:
0x000174258a024c00Portinformation:
GigabitEthernet3/0/1
GigabitEthernet3/0/2
GigabitEthernet3/0/3Activechannelinformation:
Controller0IPaddress:
192.168.2.225port:
6633
以上信息表明以太接口GigabitEthernet3/0/1、GigabitEthernet3/0/2、GigabitEthernet3/0/3已配置为OpenFlow端口,即可以进行OpenFlow数据转发。
#查看SwitchA与控制器的连接信息。
displayopenflowinstance1controllerInstance1controllerinformation:
Reconnectinterval:
60(s)Echointerval:
5(s)
ControllerID:
0
ControllerIPaddress:
192.168.2.225Controllerport:
6633
Controllerrole:
Equal
Connecttype:
TCP
Connectstate:
Established
Packetssent:
132
Packetsreceived:
434
SSLpolicy:
--
VRFname:
--
以上信息表明SwithcA已与控制器建立连接。
#查看SwitchA上的流表信息。
displayopenflowinstance1flow-tableInstance1flowtableinformation:
Table0information:
Tabletype:
Extensibility,flowentrycount:
1,totalflowentrycount:
1
MissRule(default)flowentryinformation:
cookie:
0x0,priority:
0,hardtime:
0,idletime:
0,flags:
flow_send_rem,bytecount:
--,packetcount:
0
Matchinformation:
anyInstructioninformation:
Writeactions:
Outputinterface:
Controller,sendlength:
65509bytes
以上信息表明此时SwitchA上只有一条优先级为0的TableMiss流表项,且该条流表项的动作为上送控制器。
#HostApingHostB。
Ping10.1.1.2(10.1.1.2):
56databytes,pressCTRL_Ctobreak
56bytesfrom10.1.1.2:
icmp_seq=0ttl=255time=4.582ms
56bytesfrom10.1.1.2:
icmp_seq=1ttl=255time=1.299ms
56bytesfrom10.1.1.2:
icmp_seq=2ttl=255time=1.389ms
56bytesfrom10.1.1.2:
icmp_seq=3ttl=255time=6.688ms
56bytesfrom10.1.1.2:
icmp_seq=4ttl=255time=1.294ms
---Pingstatisticsfor10.1.1.2---
5packet(s)transmitted,5packet(s)received,0.0%packetlossround-tripmin/avg/max/std-dev=1.294/3.050/6.688/2.213ms
以上信息表明HostA与HostB之间是互通的。
#查看SwitchA上的流表信息。
displayopenflowinstance1flow-tableInstance1flowtableinformation:
Table0information:
Tabletype:
Extensibility,flowentrycount:
4,totalflowentrycount:
4
MissRule(default)flowentryinformation:
cookie:
0x0,priority:
0,hardtime:
0,idletime:
0,flags:
flow_send_rem,bytecount:
--,packetcount:
0
Matchinformation:
anyInstructioninformation:
Writeactions:
Outputinterface:
Controller,sendlength:
65509bytes
Flowentry1information:
cookie:
0x2328,priority:
29999,hardtime:
0,idletime:
300,flags:
flow_send_rem,bytecount:
--,packetcount:
1
Matchinformation:
Inputinterface:
GE3/0/3
EthernetdestinationMACaddress:
0cda-41b1-d1c5EthernetdestinationMACaddressmask:
ffff-ffff-ffffEthernetsourceMACaddress:
7425-8a0f-8034
EthernetsourceMACaddressmask:
ffff-ffff-ffff
Ethernettype:
0x0806Instructioninformation:
Writeactions:
Outputinterface:
GE3/0/1
Flowentry2information:
cookie:
0x2328,priority:
29999,hardtime:
0,idletime:
300,flags:
flow_send_rem,bytecount:
--,packetcount:
4
Matchinformation:
Inputinterface:
GE3/0/1
EthernetdestinationMACaddress:
7425-8a0f-8034
EthernetdestinationMACaddressmask:
ffff-ffff-ffff
EthernetsourceMACaddress:
0cda-41b1-d1c5
EthernetsourceMACaddressmask:
ffff-ffff-ffff
Ethernettype:
0x0800Instructioninformation:
Writeactions:
Outputinterface:
GE3/0/3
Flowentry3information:
cookie:
0x2328,priority:
29999,hardtime:
0,idletime:
300,flags:
flow_send_rem,bytecount:
--,packetcount:
4
Matchinformation:
Inputinterface:
GE3/0/3
EthernetdestinationMACaddress:
0cda-41b1-d1c5
EthernetdestinationMACaddressmask:
ffff-ffff-ffff
EthernetsourceMACaddress:
7425-8a0f-8034
EthernetsourceMACaddressmask:
ffff-ffff-ffff
Ethernettype:
0x0800Instructioninformation:
Writeactions:
Outputinterface:
GE3/0/1
以上信息表明HostA和HostC之间ARP应答报文和ICMP请求/应答报文成功触发控制器下发流表项,且相应的数据报文基于下发的流表项进行转发。
#HostCpingHostD。
Ping20.1.1.2(20.1.1.2):
56databytes,pressCTRL_Ctobreak
56bytesfrom20.1.1.2:
icmp_seq=0ttl=255time=1.620ms
56bytesfrom20.1.1.2:
icmp_seq=1ttl=255time=6.625ms
56bytesfrom20.1.1.2:
icmp_seq=2ttl=255time=1.454ms
56bytesfrom20.1.1.2:
icmp_seq=3ttl=255time=1.134ms
56bytesfrom20.1.1.2:
icmp_seq=4ttl=255time=1.260ms
---Pingstatisticsfor20.1.1.2---
5packet(s)transmitted,5packet(s)received,0.0%packetlossround-tripmin/avg/max/std-dev=1.134/2.419/6.625/2.110ms
以上信息表明HostC与HostD之间是互通的。
#再次查看SwitchA上的流表信息。
displayopenflowinstance1flow-tableInstance1flowtableinformation:
Table0information:
Tabletype:
Extensibility,flowentrycount:
7,totalflowentrycount:
7
MissRule(default)flowentryinformation:
cookie:
0x0,priority:
0,hardtime:
0,idletime:
0,flags:
flow_send_rem,bytecount:
--,packetcount:
0
Matchinformation:
anyInstructioninformation:
Writeactions:
Outputinterface:
Controller,sendlength:
65509bytes
Flowentry1information:
cookie:
0x2328,priority:
29999,hardtime:
0,idletime:
300,flags:
flow_send_rem,bytecount:
--,packetcount:
1
Matchinformation:
Inputinterface:
GE3/0/3
EthernetdestinationMACaddress:
0cda-41b1-d1c5EthernetdestinationMACaddressmask:
ffff-ffff-ffffEthernetsourceMACaddress:
7425-8a0f-8034
EthernetsourceMACaddressmask:
ffff-ffff-ffff
Ethernettype:
0x0806Instructioninformation:
Writeactions:
Outputinterface:
GE3/0/1
Flowentry2information:
cookie:
0x2328,priority:
29999,hardtime:
0,idletime:
300,flags:
flow_send_rem,bytecount:
--,packetcount:
4
Matchinformation:
Inputinterface:
GE3/0/1
EthernetdestinationMACaddress:
7425-8a0f-8034
EthernetdestinationMACaddressmask:
ffff-ffff-ffff
EthernetsourceMACaddress:
0cda-41b1-d1c5
EthernetsourceMACaddressmask:
ffff-ffff-ffff
Ethernettype:
0x0800Instructioninformation:
Writeactions:
Outputinterface:
GE3/0/3
Flowentry3information:
cookie:
0x2