02-H3C_MC-NAT典型配置举例
本章节下载: 02-H3C_MC-NAT典型配置举例 (274.44 KB)
H3C MC-NAT典型配置举例
资料版本:6W100-20201031
产品版本:Release 7595
Copyright © 2020 新华三技术有限公司 版权所有,保留一切权利。 非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。 除新华三技术有限公司的商标外,本手册中出现的其它公司的商标、产品标识及商品名称,由各自权利人拥有。 本文档中的信息可能变动,恕不另行通知。 |
目 录
本文档介绍了MC-NAT(Multicast Network Address Transform,组播网络地址转换)的配置举例。
MC-NAT是通过控制器下发Openflow流表和组表,控制从来自公网源端设备的流量按需转发到私网不同的终端上。并且在转发报文之前,根据组表将报文的IP、port、vlan和mac修改为与私网终端匹配的值。
本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。本文档中所有配置举例中使用的控制器均为OVS(Open vSwitch,开放虚拟交换机)控制器。
本文假设您已了解MC-NAT特性。
如图1所示,交换机SwitchA从Internet接收到来自视频源端Source 1的流量。现要求通过OVS控制器下发Openflow流表和Group Table来实现:
· 将从VLAN 4081收到的Source 1发送的公网报文地址转换成私网地址,并按不同主机IP修改报文的目的IP、目的MAC和目的UDP端口;
· 将转换后的报文分别发送给私网主机Host A和Host B。
图1 MC-NAT基本功能配置举例组网图
设备名 |
MAC |
IP |
UDP |
Source 1 |
00:02:fc:00:22:2b |
11.110.5.100 |
6457 |
Host A |
00:e0:4c:68:0e:d4 |
192.168.4.2 |
4488 |
Host B |
00:50:56:c0:00:08 |
192.168.5.2 |
2356 |
· 为了使Openflow实例与控制器建立连接,需要配置交换机与控制器之间路由可达,本例中以网管口作为与OVS控制器通信的接口。
· 为了使组播流量能让终端接收到,需要通过控制器下发Group Table,匹配从Source1收到的报文,并修改报文的VLAN ID、目的IP、目的MAC和目的UDP端口,从HGE3/0/4和HGE3/0/5端口发出。
# 创建VLAN,并将对应的以太网接口加入VLAN。
<SwitchA> system-view
[SwitchA] vlan 4 5 4081
[SwitchA] interface hundredgige 3/0/1
[SwitchA-HundredGigE3/0/1] port link-type trunk
[SwitchA-HundredGigE3/0/1] port trunk permit vlan 4081
[SwitchA-HundredGigE3/0/1] quit
[SwitchA] interface hundredgige 3/0/4
[SwitchA-HundredGigE3/0/4] port link-type trunk
[SwitchA-HundredGigE3/0/4] port trunk permit vlan 4
[SwitchA-HundredGigE3/0/4] quit
[SwitchA] interface hundredgige 3/0/5
[SwitchA-HundredGigE3/0/5] port link-type trunk
[SwitchA-HundredGigE3/0/5] port trunk permit vlan 5
[SwitchA-HundredGigE3/0/5] quit
# 配置M-GigabitEthernet 0/0/0接口地址用户和控制器建立连接。
[SwitchA] interface M-GigabitEthernet 0/0/0
[SwitchA-M-GigabitEthernet0/0/0] ip address 172.16.147.136 255.255.0.0
[SwitchA-M-GigabitEthernet0/0/0] quit
# 创建OpenFlow全局实例。
[SwitchA] openflow instance 1
[SwitchA-of-inst-1] classification global
# 配置控制器0的IP地址并激活实例。
[SwitchA-of-inst-1] controller 0 address ip 172.16.147.101
[SwitchA-of-inst-1] active instance
[SwitchA-of-inst-1] quit
# 在控制器上创建组表group1,指定出端口1为HGE3/0/4,修改VLANID为4、目的IP为192.168.4.2、目的MAC为00:e0:4c:68:0e:d4、目的UDP端口为4488;指定出端口2为HGE3/0/5,修改VLANID为5、目的IP为192.168.5.2、目的MAC为00:50:56:c0:00:08、目的UDP端口为2356。
[root@openflowvm:~/controller0]# ./ovs-appctl send_group_str 'command(add),type(
all),group_id(1),bucket(actions(output(742),set_field(vlan_vid(4+1)),set_field(eth_dst(00:e0:4c:68:0e:d4)),set_field(ipv4_dst(192.168.4.2)),set_field(udp_dst(4488)))),bucket(actions(output(743),set_field(vlan_vid(5+1)),set_field(eth_dst(00:50:56:c0:00:08)),set_field(ipv4_dst(192.168.5.2)),set_field(udp_dst(2356))))'
22:46:56|tcp:172.16.147.136:4425: sent (Success): OFPT_GROUP_MOD (xid:31, len:16
0)
22:46:56|OFPT_GROUP_MOD (xid:31)
# Group_Mod
|- command = add
|- type = all
|- group_id = 1
|- bucket
|- weight = 0
|- watch_port = any
|- watch_group = any
|- actions
|- output,742 [max_len = 128]
|- set_field,vlan_vid,4+1
|- set_field,eth_dst,00:e0:4c:68:0e:d4
|- set_field,ipv4_dst,192.168.4.2
|- set_field,udp_dst,4488
|- bucket
|- weight = 0
|- watch_port = any
|- watch_group = any
|- actions
|- output,743 [max_len = 128]
|- set_field,vlan_vid,5+1
|- set_field,eth_dst,00:50:56:c0:00:08
|- set_field,ipv4_dst,192.168.5.2
|- set_field,udp_dst,2356
[root@openflowvm:~/controller0]#
# 将匹配入端口为HGE3/0/1、VLANID为4081、源IP为10.110.5.100、源MAC为00:02:fc:00:22:2b、源UDP端口为6457的报文,执行组表group1的动作。
[root@openflowvm:~/controller0]# ./ovs-appctl send_flow_str 'command(add),table_
id(0),priority(1),match(in_port(739),vlan_vid(4081+1),eth_src(00:02:fc:00:22:2b),eth_type(0x800),ipv4_src(10.110.5.100),ip_proto(17),udp_src(6457)),instruction(write_actions(group(1)))'
23:08:24|tcp:172.16.147.136:4425: sent (Success): OFPT_FLOW_MOD (xid:35, len:120
)
23:08:24|OFPT_FLOW_MOD (xid:35)
# Flow_Mod (48)
|- cookie = 0x0000000000000000
|- cookie_mask = 0x0000000000000000
|- table_id = 0
|- command = add
|- idle_timeout = 0
|- hard_timeout = 0
|- priority = 1
|- buffer_id = no_buffer
|- out_port = any
|- out_group = any
|- flags = 0
|- match
|- in_port,739
|- vlan_vid,4081+1
|- eth_src,00:02:fc:00:22:2b
|- eth_type,0x0800
|- ipv4_src,10.110.5.100
|- ip_proto,17
|- udp_src,6457
|- instructions
|- write_actions
|- group,1
[root@openflowvm:~/controller0]#
在Switch A上进行验证。
# 查看Switch A上Group流表的信息。
[SwitchA] display openflow instance 1 group
Instance 1 group table information:
Group count: 1
Group entry 1:
Type: All, byte count: 0, packet count: 0
Bucket 1 information:
Action count 2, watch port: any, watch group: any
Byte count 0, packet count 0
Set field:
Ethernet destination MAC address: 00e0-4c68-0ed4
VLAN ID: 4
IPv4 destination address: 192.168.4.2
UDP destination port: 4488
Output interface: HGE3/0/4
Bucket 2 information:
Action count 2, watch port: any, watch group: any
Byte count 0, packet count 0
Set field:
Ethernet destination MAC address: 0050-56c0-0008
VLAN ID: 5
IPv4 destination address: 192.168.5.2
UDP destination port: 2356
Output interface: HGE3/0/5
Referenced information:
Count: 1
Flow table: 0
Flow entry: 1
以上信息表明,Group1指定出端口1为HGE3/0/4,指定出端口2为HGE3/0/5,将报文的相关字段修改为与其端口对应的字段。
[SwitchA] display openflow instance 1 flow
Instance 1 flow table information:
Table 0 information:
Table type: Extensibility, flow entry count: 1, total flow entry count: 2
MissRule (default) flow entry information:
cookie: 0x0, priority: 0, hard time: 0, idle time: 0, flags: reset_counts,
byte count: 383689, packet count: 3330
Create time:19:07:20 01/06/2019, Last modified time:19:07:20 01/06/2019
Match information: any
Instruction information:
Write actions:
Drop
Flow entry 1 information:
cookie: 0x0, priority: 1, hard time: 0, idle time: 0, flags: none,
byte count: 0, packet count: 0
Create time:19:30:33 01/06/2019, Last modified time:19:30:33 01/06/2019
Match information:
Input interface: HGE3/0/1
Ethernet source MAC address: 0002-fc00-222b
Ethernet source MAC address mask: ffff-ffff-ffff
Ethernet type: 0x0800
VLAN ID: 4081, mask: 0xfff
IP protocol: 17
IPv4 source address: 10.110.5.100, mask: 255.255.255.255
UDP source port: 6457, mask: 0xffff
Instruction information:
Write actions:
Group: 1
以上信息表明匹配入端口为HGE3/0/1、VLANID为4081、源IP为10.110.5.100、源MAC为0002-fc00-222b 和源UDP端口为6457的报文执行了group1的动作。
· Switch A:
#
interface M-GigabitEthernet0/0/0
ip address 172.16.147.136 255.255.0.0
#
openflow instance 1
classification global
controller 0 address ip 172.16.147.101
active instance
#
interface HundredGigE3/0/1
port link-mode bridge
port link-type trunk
port trunk permit vlan 1 4081
#
interface HundredGigE3/0/4
port link-mode bridge
port link-type trunk
port trunk permit vlan 1 4
#
interface HundredGigE3/0/5
port link-mode bridge
port link-type trunk
port trunk permit vlan 1 5
#
· H3C S12500G-AF系列以太网交换机 OpenFlow配置指导-R759X
· H3C S12500G-AF系列以太网交换机 OpenFlow命令参考-R759X
不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!