免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2326 | 回复: 0

常用配置之不同VLAN与路由器通信(华为) [复制链接]

论坛徽章:
0
发表于 2009-09-19 08:07 |显示全部楼层

配置不同VLAN通过路由器通信


应用环境

当不同的VLAN之间需要进行互通时,可以通过路由器来进行不同VLAN间的路由,从而实现不同VLAN的互通。路由器实现VLAN间互通有两种方式:

  • 通过子接口实现

当要进行互通的VLAN数量较多,而且网络的扩展性要求较高时,应采用子接口方式实现VLAN间互通。

  • 通过VLAN接口实现

当要进行互通的VLAN数量有限,通信量大且对速率要求较高,而且网络不易扩展时,应采用VLAN接口方式实现互通。


配置思路

在配置不同VLAN通过路由器通信时,采用如下的配置思路:
1.         为需要互通的VLAN分配路由器接口
2.         配置各接口的IP地址和属性


配置注意事项


  • 采用子接口方式实现VLAN间互通时,应综合考虑路由器实际端口速率,子接口数目和VLAN间通信速率的要求,选取合适的端口和子接口数目。


  • 配置路由器子接口的IP地址时,注意与对应的VLAN主机的IP地址在同一个网段。



配置实例一

组网需求
如下图所示,路由器Router的路由式接口GE1/0/0与SwitchA上行口相连,路由式接口GE2/0/0与SwitchB上行口相连。
SwitchA的下行按端口划分为VLAN10和20。SwitchB的下行按端口划分为VLAN30和40。
要求VLAN10、20、30及40之间能够互通。
不同VLAN通过路由器子接口通信

适用产品和版本
适用于NE40E/NE80E设备,版本为(VRP5.30_31)及后续版本。
配置步骤
步骤 1     配置连接SwitchA的接口
# 创建并配置以太网子接口GE1/0/0.1,对应VLAN 10。
system-view
[Router] interface gigabitethernet 1/0/0.1
[Router-GigabitEthernet1/0/0.1] vlan-type dot1q 10
[Router-GigabitEthernet1/0/0.1] ip address 10.110.3.3 255.255.255.0
[Router-GigabitEthernet1/0/0.1] quit
# 创建并配置以太网子接口GE1/0/0.2,对应VLAN 20。
[Router] interface gigabitethernet 1/0/0.2
[Router-GigabitEthernet1/0/0.2] vlan-type dot1q 20
[Router-GigabitEthernet1/0/0.2] ip address 10.110.4.3 255.255.255.0
[Router-GigabitEthernet1/0/0.2] quit
步骤 2     配置连接SwitchB的接口
# 创建并配置以太网子接口GE2/0/0.1,对应VLAN 30。
[Router] interface gigabitethernet 2/0/0.1
[Router-GigabitEthernet2/0/0.1] vlan-type dot1q 30
[Router-GigabitEthernet2/0/0.1] ip address 10.110.5.3 255.255.255.0
[Router-GigabitEthernet2/0/0.1] quit
# 创建并配置以太网子接口GE2/0/0.2,对应VLAN 40。
[Router] interface gigabitethernet 2/0/0.2
[Router-GigabitEthernet2/0/0.2] vlan-type dot1q 40
[Router-GigabitEthernet2/0/0.2] ip address 10.110.6.3 255.255.255.0
[Router-GigabitEthernet2/0/0.2] quit
步骤 3     配置各VLAN内主机的默认网关为对应各VLAN的路由器子接口的IP地址。
验证结果
VLAN 10内的主机与VLAN 20内的主机可以互通。
C:\>ping 10.110.4.1
Pinging 10.110.4.1 with 32 bytes of data:

Reply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 time
Ping statistics for 10.110.3.1 :
     Packets: Sent = 4,Received =4,Lost = 0 ,
Approximates round trip times in milli-seconds:
     Minimum =0ms,Maximum =0ms,Average =0ms
VLAN 10内的主机与VLAN 30内的主机可以互通。
C:\>ping 10.110.5.1
Pinging 10.110.5.1 with 32 bytes of data:

Reply from 10.110.5.1: bytes=32 timeReply from 10.110.5.1: bytes=32 timeReply from 10.110.5.1: bytes=32 timeReply from 10.110.5.1: bytes=32 time
Ping statistics for 10.110.3.1 :
     Packets: Sent = 4,Received =4,Lost = 0 ,
Approximates round trip times in milli-seconds:
     Minimum =0ms,Maximum =0ms,Average =0ms
配置文件
Router的配置文件。
#
sysname Router
#
interface GigabitEthernet1/0/0.1
vlan-type dot1q 10
ip address 10.110.3.3 255.255.255.0
#
interface GigabitEthernet1/0/0.2
vlan-type dot1q 20
ip address 10.110.4.3 255.255.255.0
#
interface GigabitEthernet2/0/0.1
vlan-type dot1q 30
ip address 10.110.5.3 255.255.255.0
#
interface GigabitEthernet2/0/0.2
vlan-type dot1q 40
ip address 10.110.6.3 255.255.255.0
#
return


配置实例二

组网需求
如下图所示,路由器Router的路由式接口GE1/0/0连接VLAN10内的主机,路由式接口GE1/0/1连接VLAN20内的主机。
要求VLAN10和VLAN 20之间能够互通。
不同VLAN通过路由器VLANIF通信

适用产品和版本
适用于NE40E/80E设备,版本为(VRP5.30_31)及后续版本。
配置步骤
步骤 1     配置VLAN10。
# 将Router连接VLAN10的接口切换成二层模式。
system-view
[Router] interface gigabitethernet 1/0/0
[Router-GigabitEthernet1/0/0] portswitch
[Router-GigabitEthernet1/0/0] quit
# 创建VLAN10。
[Router] vlan 10
# 向VLAN10中加入GE1/0/0。
[Router-vlan10] port gigabitethernet 1/0/0
[Router-vlan10] quit
# 配置VLAN接口。
[Router] interface vlanif 10
[Router-Vlanif10] ip address 10.110.3.3 24
[Router-Vlanif10] quit
步骤 2     配置VLAN20。
# 将Router连接VLAN20的接口切换成二层模式。
[Router] interface gigabitethernet 1/0/1
[Router-GigabitEthernet1/0/1] portswitch
[Router-GigabitEthernet1/0/1] quit
# 创建VLAN20。
[Router] vlan 20
# 向VLAN20中加入GE1/0/1。
[Router-vlan20] port gigabitethernet 1/0/1
[Router-vlan20] quit
# 配置VLAN接口。
[Router] interface vlanif 20
[Router-Vlanif20] ip address 10.110.4.3 24
[Router-Vlanif20] quit
步骤 3     配置VLAN10内的主机默认网关为10.110.3.3,VLAN20内的主机默认网关为10.110.4.3。
验证结果
VLAN 10内的主机与VLAN 20内的主机可以互通。
C:\>ping 10.110.4.1
Pinging 10.110.4.1 with 32 bytes of data:

Reply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 timeReply from 10.110.4.1: bytes=32 time
Ping statistics for 10.110.3.1 :
     Packets: Sent = 4,Received =4,Lost = 0 ,
Approximates round trip times in milli-seconds:
     Minimum =0ms,Maximum =0ms,Average =0ms
配置文件
Router的配置文件。
#
sysname Router
#
vlan 10
vlan 20
#
interface Vlanif10
ip address 10.110.3.3 255.255.255.0
#
interface Vlanif20
ip address 10.110.4.3 255.255.255.0
#
interface GigabitEthernet1/0/0
portswitch
port default vlan 10
#
interface GigabitEthernet1/0/1
portswitch
port default vlan 20


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/104128/showart_2055651.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP