配置基于端口的VLAN(NE路由器)
应用环境
VLAN将一个物理的LAN在逻辑上划分成多个广播域(多个VLAN)。VLAN内的主机间可以直接通信,而VLAN间不能直接互通,这样,广播报文被限制在一个VLAN内。如果要实现在VLAN间通信,需要建立IP路由。可以配置VLANIF接口,实现VLAN间通信。
以太网接口板分为两类:
交换式以太网接口板
路由式以太网接口板
只有交换式以太网接口才能加入到VLAN。
如果路由器提供路由式以太网接口板,可以通过命令切换到二层模式(交换式以太网接口板),再配置VLANIF,实现VLAN间的通信。
配置思路
配置基于端口的VLAN间通信时,采用如下的配置思路:
将路由式接口配置为交换式接口
创建一个VLAN并加入接口
配置注意事项
应综合考虑路由器实际端口速率和VLAN对通信速率的要求,选取合适的路由器端口。
配置路由器接口的IP地址时,注意与对应的VLAN主机的IP地址在同一个网段。
配置实例
组网需求
如下图所示,创建两个VLAN:VLAN2和VLAN3。
VLAN2包含端口GE1/0/0和GE2/0/0,VLAN3包含端口GE3/0/0和GE4/0/0。这些GE端口均是路由式接口。
VLAN2与VLAN3之间能够通过VLANIF接口互相通信。
VLAN配置示例图
数据准备
为完成此配置例,需准备如下的数据:
以太网端口Gigabit Ethernet1/0/0和Gigabit Ethernet2/0/0属于VLAN2
以太网端口Gigabit Ethernet3/0/0和Gigabit Ethernet4/0/0属于VLAN3
VLANIF2的IP地址为120.1.1.1/24
VLANIF3的IP地址为130.1.1.1/24
配置步骤
步骤 1 配置VLAN2
# 将接口切换成二层模式。
<Router> system-view
[Router] interface gigabitethernet 1/0/0
[Router-GigabitEthernet1/0/0] portswitch
[Router-GigabitEthernet1/0/0] quit
[Router] interface gigabitethernet 2/0/0
[Router-GigabitEthernet2/0/0] portswitch
[Router-GigabitEthernet2/0/0] quit
# 创建VLAN2。
[Router] vlan 2
# 向VLAN2中加入GE1/0/0和GE2/0/0。
[Router-vlan2] port gigabitethernet 1/0/0 2/0/0
[Router-vlan2] quit
# 配置VLANIF接口。
[Router] interface vlanif 2
[Router-Vlanif2] ip address 120.1.1.1 24
[Router-Vlanif2] quit
步骤 2 配置VLAN3
# 将接口切换成二层模式。
[Router] interface gigabitethernet 3/0/0
[Router-GigabitEthernet3/0/0] portswitch
[Router-GigabitEthernet3/0/0] quit
[Router] interface gigabitethernet 4/0/0
[Router-GigabitEthernet4/0/0] portswitch
[Router-GigabitEthernet4/0/0] quit
# 创建VLAN3。
[Router] vlan 3
# 向VLAN3中加入GE3/0/0和GE4/0/0。
[Router-vlan3] port gigabitethernet 3/0/0 4/0/0
[Router-vlan3] quit
# 配置VLANIF接口。
[Router] interface vlanif 3
[Router-Vlanif3] ip address 130.1.1.1 24
[Router-Vlanif3] quit
检验配置结果
在各主机上配置缺省网关为本主机所属VLAN的VLANIF接口的IP地址。
配置完成后,VLAN2中的主机能够和VLAN3中的主机通信。
C:\>ping 120.1.1.2
Pinging 120.1.1.2 with 32 bytes of data:
Reply from 120.1.1.2: bytes=32 time<1ms TTL=128
Reply from 120.1.1.2: bytes=32 time<1ms TTL=128
Reply from 120.1.1.2: bytes=32 time<1ms TTL=128
Reply from 120.1.1.2: bytes=32 time<1ms TTL=128
Ping statistics for 130.1.1.3 :
Packets: Sent = 4,Received =4,Lost = 0 <0% loss>,
Approximates round trip times in milli-seconds:
Minimum =0ms,Maximum =0ms,Average =0ms
配置文件
#
sysname Router
#
vlan batch 2 to 3
#
interface Vlanif2
ip address 120.1.1.1 255.255.255.0
#
interface Vlanif3
ip address 130.1.1.1 255.255.255.0
#
interface GigabitEthernet1/0/0
portswitch
port default vlan 2
#
interface GigabitEthernet2/0/0
portswitch
port default vlan 2
#
interface GigabitEthernet3/0/0
portswitch
port default vlan 3
#
interface GigabitEthernet4/0/0
portswitch
port default vlan 3
#
return
|
|
||
|
|
||
|
|
开班时间 | 班级类型 | 报名情况 |
---|
7月14日 |
H3CTE认证 |
热报中 |
7月7日 |
H3CSE培训 |
热报中 |
7月7日 |
H3CNE认证 |
热报中 |
7月14日 |
H3CTE认证 |
热报中 |
7月7日 |
H3CSE培训 |
热报中 |
7月7日 |
H3CNE培训 |
热报中 |
7月14日 |
H3CTE认证 |
热报中 |
7月7日 |
H3CSE认证 |
热报中 |
7月7日 |
H3CNE培训 |
热报中 |
7月21日 |
H3CIMC培训 |
热报中 |
7月8日 |
H3C无线培训 |
热报中 |
7月8日 |
H3CEAD培训 |
热报中 |
7月28日 |
H3CPME认证 |
热报中 |
7月14日 |
H3C安全认证 |
热报中 |
7月21日 |
H3CIMC培训 |
热报中 |
7月8日 |
H3C无线培训 |
热报中 |
7月8日 |
H3CEAD培训 |
热报中 |
7月28日 |
H3CPME认证 |
热报中 |
7月14日 |
H3C安全认证 |
热报中 |
7月21日 |
H3CIMC培训 |
热报中 |
7月8日 |
H3C无线培训 |
热报中 |
7月8日 |
H3CEAD培训 |
热报中 |
7月28日 |
H3CPME认证 |
热报中 |
7月14日 |
H3C安全认证 |
热报中 |