配置同网段用户通过VXLAN隧道互通示例
通过典型的应用场景描述了如何配置同网段用户通过VXLAN隧道互通示例。
组网需求
如图16-19所示,某企业在不同的数据中心中都拥有自己的VM,服务器1上的VM1属于VLAN10,服务器2上的VM1属于VLAN20,且位于同网段。现需要通过VXLAN隧道实现不同数据中心相同VM的互通。
配置思路
- 分别在Device1、Device2和Device3上配置路由协议,保证网络三层互通。
- 分别在Device1和Device3上配置业务接入点实现区分业务流量。
- 分别在Device1和Device3上配置VXLAN隧道实现转发业务流量。
数据准备
为完成此配置例,需准备如下的数据:
- VM所属的VLAN ID分别是VLAN10和VLAN20。
- 网络中设备互连的接口IP地址。
- 网络中使用的IGP(Internal Gateway Protocol)路由类型是OSPF(Open Shortest Path First)。
- 广播域BD ID是10。
- VXLAN网络标识VNI ID是5010。
操作步骤
- 配置路由协议
按图16-19分别配置Device1、Device2和Device3各接口IP地址。
# 配置Device1<HUAWEI> system-view
[~HUAWEI] sysname Device1
[*HUAWEI] commit
[~Device1] interface loopback 1
[*Device1-LoopBack1] ip address 2.2.2.2 32
[*Device1-LoopBack1] quit
[*Device1] interface gigabitethernet 0/1/1
[*Device1-GigabitEthernet0/1/1] ip address 192.168.1.1 24
[*Device1-GigabitEthernet0/1/1] quit
[*Device1] ospf
[*Device1-ospf-1] area 0
[*Device1-ospf-1-area-0.0.0.0] network 2.2.2.2 0.0.0.0
[*Device1-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[*Device1-ospf-1-area-0.0.0.0] quit
[*Device1-ospf-1] quit
[*Device1] commit
Device2、Device3的配置与Device1配置类似,这里不再赘述。具体配置过程略,请参考配置文件。
OSPF成功配置后,Device之间可通过OSPF协议发现对方的Loopback接口的IP地址,并能互相ping通。以Device1 ping Device3的显示为例。[~Device1] ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=254 time=5 ms Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=254 time=2 ms Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=254 time=2 ms Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=254 time=3 ms Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=254 time=3 ms --- 4.4.4.4 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 2/3/5 ms
- 分别在Device1、Device3上配置业务接入点
# 配置Device1
[~Device1] bridge-domain 10
[*Device1-bd10] quit
[*Device1] interface gigabitethernet0/1/2.1 mode l2
[*Device1-GigabitEthernet0/1/2.1] encapsulation dot1q vid 10
[*Device1-GigabitEthernet0/1/2.1] rewrite pop single
[*Device1-GigabitEthernet0/1/2.1] bridge-domain 10
[*Device1-GigabitEthernet0/1/2.1] quit
[*Device1] commit
Device3的配置与Device1配置类似,这里不再赘述。具体配置过程略,请参考配置文件。
- 分别在Device1、Device3上配置VXLAN隧道
# 配置Device1
[~Device1] bridge-domain 10
[~Device1-bd10] vxlan vni 5010
[*Device1-bd10] quit
[*Device1] interface nve 1
[*Device1-Nve1] source 2.2.2.2
[*Device1-Nve1] vni 5010 head-end peer-list 4.4.4.4
[*Device1-Nve1] quit
[*Device1] commit
Device3的配置与Device1配置类似,这里不再赘述。具体配置过程略,请参考配置文件。
- 检查配置结果
上述配置成功后,在Device1、Device3上执行display vxlan vni命令可查看到VNI的状态是Up;执行display vxlan tunnel命令可查看到VXLAN隧道的信息。以Device1显示为例。
[~Device1] display vxlan vni
Number of vxlan vni: 1 VNI BD-ID State --------------------------------------- 5010 10 up
[~Device1] display vxlan tunnel
Number of vxlan tunnel : 1 Tunnel ID Source Destination State Type Uptime ------------------------------------------------------------------- 4026531842 2.2.2.2 4.4.4.4 up static 0028h16m
配置完成后,同网段用户通过VXLAN隧道可以互通。
配置文件
Device1的配置文件
# sysname Device1 # bridge-domain 10 vxlan vni 5010 # interface GigabitEthernet0/1/1 undo shutdown ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet0/1/2 undo shutdown # interface GigabitEthernet0/1/2.1 mode l2 encapsulation dot1q vid 10 rewrite pop single bridge-domain 10 # interface LoopBack1 ip address 2.2.2.2 255.255.255.255 # interface Nve1 source 2.2.2.2 vni 5010 head-end peer-list 4.4.4.4 # ospf 1 area 0.0.0.0 network 2.2.2.2 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
Device2的配置文件
# sysname Device2 # interface GigabitEthernet0/1/1 undo shutdown ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet0/1/2 undo shutdown ip address 192.168.2.1 255.255.255.0 # interface LoopBack1 ip address 3.3.3.3 255.255.255.255 # ospf 1 area 0.0.0.0 network 3.3.3.3 0.0.0.0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 # return
Device3的配置文件
# sysname Device3 # bridge-domain 10 vxlan vni 5010 # interface GigabitEthernet0/1/1 undo shutdown ip address 192.168.2.2 255.255.255.0 # interface GigabitEthernet0/1/2 undo shutdown # interface GigabitEthernet0/1/2.1 mode l2 encapsulation dot1q vid 20 rewrite pop single bridge-domain 10 # interface LoopBack1 ip address 4.4.4.4 255.255.255.255 # interface Nve1 source 4.4.4.4 vni 5010 head-end peer-list 2.2.2.2 # ospf 1 area 0.0.0.0 network 4.4.4.4 0.0.0.0 network 192.168.2.0 0.0.0.255 # return