
子接口与OSPF结合跨越三层网络通信配置示例
1、组网需求
图1 配置通过子接口跨越三层网络通信组网图
如图1所示,SwitchA和SwitchB分别下挂VLAN10和VLAN20的二层网络,SwitchA和SwitchB之间通过三层网络互通,三层网络采用OSPF协议。
要求两个二层网络的PC实现二层隔离三层互通。
2、配置思路
2.1、配置接口所属的VLAN。
2.2、配置VLANIF接口的IP地址。
2.3、配置子接口的封装方式。
2.4、配置子接口允许通过的VLAN。
2.5、配置子接口的IP地址。
2.6、配置OSPF基本功能。
说明:
子接口允许通过的VLAN不能在全局创建。
3、操作步骤
3.1、配置SwitchA
# 创建VLAN
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 30
# 配置接口加入VLAN
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] port link-type trunk
[SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 30
[SwitchA-GigabitEthernet1/0/2] quit
# 配置VLANIF接口的IP地址
[SwitchA] interface vlanif 30
[SwitchA-Vlanif30] ip address 10.10.30.1 24
[SwitchA-Vlanif30] quit
# 创建并配置子接口GE1/0/1.1
[SwitchA] interface gigabitethernet1/0/1
[SwitchA-GigabitEthernet1/0/1] port link-type hybrid
[SwitchA-GigabitEthernet1/0/1] quit
[SwitchA] interface gigabitethernet 1/0/1.1
[SwitchA-GigabitEthernet1/0/1.1] dot1q termination vid 10
[SwitchA-GigabitEthernet1/0/1.1] ip address 10.10.10.1 24
[SwitchA-GigabitEthernet1/0/1.1] arp broadcast enable
[SwitchA-GigabitEthernet1/0/1.1] quit
# 配置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] return
3.2、配置SwitchB
# 创建VLAN
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] vlan batch 30
# 配置接口加入VLAN
[SwitchB] interface gigabitethernet 1/0/1
[SwitchB-GigabitEthernet1/0/1] port link-type trunk
[SwitchB-GigabitEthernet1/0/1] port trunk allow-pass vlan 30
[SwitchB-GigabitEthernet1/0/1] quit
# 配置VLANIF接口的IP地址
[SwitchB] interface vlanif 30
[SwitchB-Vlanif30] ip address 10.10.30.2 24
[SwitchB-Vlanif30] quit
# 创建并配置子接口GE1/0/2.1
[SwitchB] interface gigabitethernet1/0/2
[SwitchB-GigabitEthernet1/0/2] port link-type hybrid
[SwitchB-GigabitEthernet1/0/2] quit
[SwitchB] interface gigabitethernet 1/0/2.1
[SwitchB-GigabitEthernet1/0/2.1] dot1q termination vid 20
[SwitchB-GigabitEthernet1/0/2.1] ip address 10.10.20.1 24
[SwitchB-GigabitEthernet1/0/2.1] arp broadcast enable
[SwitchB-GigabitEthernet1/0/2.1] quit
# 配置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.30.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] return
4、检查配置结果
4.1、SwitchA下挂的二层网络中PC上配置缺省网关为GE1/0/1.1接口的IP地址10.10.10.1/24。SwitchA下挂的交换机允许VLAN10通过。
4.2、SwitchB下挂的二层网络中PC上配置缺省网关为GE1/0/2.1接口的IP地址10.10.20.1/24。SwitchB下挂的交换机允许VLAN20通过。
配置完成后,两个二层网络的PC实现二层隔离三层互通。
5、配置文件
5.1、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 GigabitEthernet1/0/1
port link-type hybrid
#
interface GigabitEthernet1/0/1.1
dot1q termination vid 10
ip address 10.10.10.1 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet1/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
5.2、SwitchB的配置文件。
#
sysname SwitchB
#
router id 2.2.2.2
#
vlan batch 30
#
interface Vlanif30
ip address 10.10.30.2 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-type trunk
port trunk allow-pass vlan 30
#
interface GigabitEthernet1/0/2
port link-type hybrid
#
interface GigabitEthernet1/0/2.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



本文地址:http://www.023wg.com/vlan/148.html
版权声明:若无注明,本文皆为“Swiers思唯网络博客”原创,转载请保留文章出处。

