配置Dot1q终结三层子接口实现跨越三层网络通信示例
组网需求
如图5-26所示,SwitchA和SwitchB分别通过三层子接口10GE1/0/1.1下挂VLAN10和VLAN20的数据中心网络,SwitchA和SwitchB之间跨越三层网络,三层网络采用OSPF协议。
要求两个数据中心网络能够三层互通。
配置思路
两个数据中心网络通过三层子接口连接到交换机,因此可通过配置Dot1q终结三层子接口实现三层互通。采用如下的思路配置Dot1q终结三层子接口实现跨越三层网络通信:
- 在SwitchC和SwitchD上创建VLAN,并配置上行接口和用户侧接口,实现将数据中心网络的报文二层转发到SwitchA和SwitchB。
配置SwitchA和SwitchB连接数据中心网络的接口,终结数据中心网络的VLAN。
配置SwitchA和SwitchB连接三层网络的接口、VLANIF和OSPF基本功能,使其能进行三层转发。
在三层网络连接SwitchA和SwitchB的边缘设备上,配置连接接口、VLANIF和OSPF基本功能,使其能与SwitchA和SwitchB三层互通,进而实现两数据中心网络间的三层互通。
三层网络连接SwitchA和SwitchB的边缘设备上的配置,请参考设备对应的配置手册,本示例不再赘述。
操作步骤
- 配置SwitchC和SwitchD
在SwitchC上创建VLAN,并将上行接口以Tagged方式加入VLAN10,用户侧接口以Untagged方式加入VLAN10;在SwitchD上创建VLAN,并将上行接口以Tagged方式加入VLAN20,用户侧接口以Untagged方式加入VLAN20。具体配置可参见配置基于接口划分VLAN示例,本示例不再赘述。
- 配置SwitchA
# 配置SwitchA连接数据中心网络的三层子接口10GE1/0/1.1,使其终结VLAN10。
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] interface 10ge1/0/1 [~SwitchA-10GE1/0/1] undo portswitch [*SwitchA-10GE1/0/1] quit [*SwitchA] interface 10ge 1/0/1.1 [*SwitchA-10GE1/0/1.1] dot1q termination vid 10 [*SwitchA-10GE1/0/1.1] ip address 10.10.10.1 24 [*SwitchA-10GE1/0/1.1] quit [*SwitchA] commit
# 创建VLAN,并配置SwitchA连接三层网络的接口10GE1/0/2允许通过该VLAN。
[~SwitchA] vlan batch 30 [*SwitchA] interface 10ge 1/0/2 [*SwitchA-10GE1/0/2] port link-type trunk [*SwitchA-10GE1/0/2] port trunk allow-pass vlan 30 [*SwitchA-10GE1/0/2] quit [*SwitchA] commit
# 创建VLANIF接口,并配置该VLANIF接口的IP地址,使SwitchA能进行三层转发。
[~SwitchA] interface vlanif 30 [*SwitchA-Vlanif30] ip address 10.10.30.1 24 [*SwitchA-Vlanif30] quit [*SwitchA] commit
# 配置OSPF基本功能
[~SwitchA] router id 1.1.1.1 [*SwitchA] ospf [*SwitchA-ospf-1] area 0 [*SwitchA-ospf-1-area-0.0.0.0] network 10.10.10.0 0.0.0.255 [*SwitchA-ospf-1-area-0.0.0.0] network 10.10.30.0 0.0.0.255 [*SwitchA-ospf-1-area-0.0.0.0] quit [*SwitchA-ospf-1] quit [*SwitchA] commit
- 配置SwitchB
# 配置SwitchB连接数据中心网络的三层子接口10GE1/0/1.1,使其终结VLAN20。
<HUAWEI> system-view [~HUAWEI] sysname SwitchB [*HUAWEI] commit [~SwitchB] interface 10ge1/0/1 [~SwitchB-10GE1/0/1] undo portswitch [*SwitchB-10GE1/0/1] quit [*SwitchB] interface 10ge 1/0/1.1 [*SwitchB-10GE1/0/1.1] dot1q termination vid 20 [*SwitchB-10GE1/0/1.1] ip address 10.10.20.1 24 [*SwitchB-10GE1/0/1.1] quit [*SwitchB] commit
# 创建VLAN,并配置SwitchA连接三层网络的接口10GE1/0/2允许通过该VLAN。
[~SwitchB] vlan batch 40 [*SwitchB] interface 10ge 1/0/2 [*SwitchB-10GE1/0/2] port link-type trunk [*SwitchB-10GE1/0/2] port trunk allow-pass vlan 40 [*SwitchB-10GE1/0/2] quit [*SwitchB] commit
# 创建VLANIF接口,并配置该VLANIF接口的IP地址,使SwitchB能进行三层转发。
[~SwitchB] interface vlanif 40 [*SwitchB-Vlanif40] ip address 10.10.40.1 24 [*SwitchB-Vlanif40] quit [*SwitchB] commit
# 配置OSPF基本功能
[~SwitchB] router id 2.2.2.2 [*SwitchB] ospf [*SwitchB-ospf-1] area 0 [*SwitchB-ospf-1-area-0.0.0.0] network 10.10.20.0 0.0.0.255 [*SwitchB-ospf-1-area-0.0.0.0] network 10.10.40.0 0.0.0.255 [*SwitchB-ospf-1-area-0.0.0.0] quit [*SwitchB-ospf-1] quit [*SwitchB] commit
- 验证配置结果
SwitchA下挂的数据中心网络中ServerA上配置缺省网关为10GE1/0/1.1接口的IP地址10.10.10.1/24。
SwitchB下挂的数据中心网络中ServerB上配置缺省网关为10GE1/0/2.1接口的IP地址10.10.20.1/24。
配置完成后,两个数据中心网络能够进行三层通信。
配置文件
SwitchA的配置文件。
# sysname SwitchA # router id 1.1.1.1 # vlan batch 30 # interface Vlanif30 ip address 10.10.30.1 255.255.255.0 # interface 10GE1/0/1 undo portswitch # interface 10GE1/0/1.1 ip address 10.10.10.1 255.255.255.0 dot1q termination vid 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 area 0.0.0.0 network 10.10.10.0 0.0.0.255 network 10.10.30.0 0.0.0.255 # return
SwitchB的配置文件。
# sysname SwitchB # router id 2.2.2.2 # vlan batch 40 # interface Vlanif40 ip address 10.10.40.1 255.255.255.0 # interface 10GE1/0/1 undo portswitch # interface 10GE1/0/1.1 ip address 10.10.20.1 255.255.255.0 dot1q termination vid 20 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 area 0.0.0.0 network 10.10.20.0 0.0.0.255 network 10.10.40.0 0.0.0.255 # return