配置Dot1q终结子接口实现跨设备VLAN间通信示例
组网需求
如图6-8所示,RouterA和RouterB分别下挂VLAN 10和VLAN 20的二层网络,RouterA和RouterB之间通过三层网络互通,三层网络采用OSPF协议。
要求两个二层网络的PC实现二层隔离三层互通。
配置思路
采用如下的思路配置通过子接口跨越三层网络通信:
配置接口所属的VLAN。
配置VLANIF接口的IP地址。
配置子接口的封装方式。
配置子接口允许通过的VLAN。
配置子接口的IP地址。
配置OSPF基本功能。
子接口允许通过的VLAN不能在全局创建。
操作步骤
- 配置RouterA
# 创建VLAN。
<Huawei> system-view [Huawei] sysname RouterA [RouterA] vlan batch 30
# 配置接口加入VLAN。
[RouterA] interface ethernet 2/0/2 [RouterA-Ethernet2/0/2] port link-type trunk [RouterA-Ethernet2/0/2] port trunk allow-pass vlan 30 [RouterA-Ethernet2/0/2] quit
# 配置VLANIF接口的IP地址。
[RouterA] interface vlanif 30 [RouterA-Vlanif30] ip address 10.10.30.1 24 [RouterA-Vlanif30] quit
# 创建并配置子接口GE1/0/1.1。
[RouterA] interface gigabitethernet 1/0/0.1 [RouterA-GigabitEthernet1/0/0.1] dot1q termination vid 10 [RouterA-GigabitEthernet1/0/0.1] ip address 10.10.10.1 24 [RouterA-GigabitEthernet1/0/0.1] arp broadcast enable [RouterA-GigabitEthernet1/0/0.1] quit
# 配置OSPF基本功能。
[RouterA] router id 1.1.1.1 [RouterA] ospf [RouterA-ospf-1] area 0 [RouterA-ospf-1-area-0.0.0.0] network 10.10.10.0 0.0.0.255 [RouterA-ospf-1-area-0.0.0.0] network 10.10.30.0 0.0.0.255 [RouterA-ospf-1-area-0.0.0.0] return
- 配置RouterB
# 创建VLAN。
<Huawei> system-view [Huawei] sysname RouterB [RouterB] vlan batch 30
# 配置接口加入VLAN。
[RouterB] interface ethernet 2/0/1 [RouterB-Ethernet2/0/1] port link-type trunk [RouterB-Ethernet2/0/1] port trunk allow-pass vlan 30 [RouterB-Ethernet2/0/1] quit
# 配置VLANIF接口的IP地址。
[RouterB] interface vlanif 30 [RouterB-Vlanif30] ip address 10.10.30.2 24 [RouterB-Vlanif30] quit
# 创建并配置子接口GE1/0/2.1。
[RouterB] interface gigabitethernet 2/0/0.1 [RouterB-GigabitEthernet2/0/0.1] dot1q termination vid 20 [RouterB-GigabitEthernet2/0/0.1] ip address 10.10.20.1 24 [RouterB-GigabitEthernet2/0/0.1] arp broadcast enable [RouterB-GigabitEthernet2/0/0.1] quit
# 配置OSPF基本功能。
[RouterB] router id 2.2.2.2 [RouterB] ospf [RouterB-ospf-1] area 0 [RouterB-ospf-1-area-0.0.0.0] network 10.10.20.0 0.0.0.255 [RouterB-ospf-1-area-0.0.0.0] network 10.10.30.0 0.0.0.255 [RouterB-ospf-1-area-0.0.0.0] return
- 验证配置结果
# RouterA下挂的二层网络中PC上配置缺省网关为GE1/0/0.1接口的IP地址10.10.10.1/24。RouterA下挂的交换机允许VLAN 10通过。
# RouterB下挂的二层网络中PC上配置缺省网关为GE2/0/0.1接口的IP地址10.10.20.1/24。RouterB下挂的交换机允许VLAN 20通过。
配置完成后,两个二层网络的PC实现二层隔离三层互通。
配置文件
- RouterA的配置文件
# sysname RouterA # router id 1.1.1.1 # vlan batch 30 # interface Vlanif30 ip address 10.10.30.1 255.255.255.0 # interface GigabitEthernet1/0/0.1 dot1q termination vid 10 ip address 10.10.10.1 255.255.255.0 arp broadcast enable # interface Ethernet2/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
- RouterB的配置文件
# sysname RouterB # router id 2.2.2.2 # vlan batch 30 # interface Vlanif30 ip address 10.10.30.2 255.255.255.0 # interface Ethernet2/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface GigabitEthernet2/0/0.1 dot1q termination vid 20 ip address 10.10.20.1 255.255.255.0 arp broadcast enable # ospf 1 area 0.0.0.0 network 10.10.20.0 0.0.0.255 network 10.10.30.0 0.0.0.255 # return