配置vlan
实验目录
一.配置vlan、trunk
1.配置H3C1的vlan,及vlan查看命令!!
[H3C1]display vlan
[H3C1]display vlan all
[H3C1]display port trunk
[H3C1]display interface e0/4/3
2.配置H3C2的vlan
3,解决默认只允许vlan1通过trunk链路
[H3C1-Ethernet0/4/3]port trunk permit vlan all
4.gvrp相当与Cisco的VTP服务
二.vlan间路由
1.三层交换trunk和hybrid
2.单臂路由
一.配置vlan、trunk
|
粗略的查看有设备上有几个vlan
[H3C1]display vlan
Total 2 VLAN exist(s).
The following VLANs exist:
1(default), 2
详细的查看设备上vlan的情况
[H3C1]display vlan all
VLAN ID: 1 //vlan1的详细信息
VLAN Type: static //vlan属于静态的,也就是说是手工创建的
Route Interface: configured
IP Address: 1.1.1.1
Subnet Mask: 255.255.255.0
Description: VLAN 0001 //对vlan的描述
Broadcast MAX-ratio: 100% //广播包在vlan链路占的百分比,可改
Tagged Ports: none //标记的,如果串行接口不在此vlan中, 那个接口将会出现在此处!
Untagged Ports: //可以说是属于本vlan的接口
Ethernet0/4/0 Ethernet0/4/1 Ethernet0/4/2
Ethernet0/4/3 Ethernet0/4/4 Ethernet0/4/5
Ethernet0/4/6 Ethernet0/4/7
VLAN ID: 2 //vlan2的详细信息
VLAN Type: static
Route Interface: configured
IP Address: 2.2.2.2
Subnet Mask: 255.255.255.0
Description: VLAN 0002
Broadcast MAX-ratio: 100%
Tagged Ports: none
Untagged Ports: none
查看vlan接口状态,可以看到vlan2是down的,原因是:默认trunk只为vlan1服务!!
[H3C1]display ip interface brief
*down: administratively down
(s): spoofing
Interface Physical Protocol IP Address
Ethernet0/1/0 up down unassigned
Vlan-interface1 up up 1.1.1.1
Vlan-interface2 down down 2.2.2.2
查看设备上开启trunk的端口,PVID属于哪个vlan,允许通过trunk的vlan!此时只有1!
[H3C1]display port trunk
Interface PVID VLAN passing
Eth0/4/3 1 1
查看trunk端口
[H3C1]display interface e0/4/3
部分显示省略
Port link-type: trunk
VLAN passing : 1(default vlan) //默认只有vlan1通过
VLAN permitted: 1(default vlan) //默认只允许vlan1通过
Trunk port encapsulation: IEEE 802.1q //封装类型只会是IEEE802.1q
|
3.解决默认只允许vlan1通过trunk链路
虽然配置完毕但是此时vlan2的接口是down的,原因上面已经看到,是默认只能vlan1通过trunk,这点是和Cisco不同的地方。
我们要在的是允许所有的vlan通过trunk链路
[H3C1]interface e0/4/3
[H3C1-Ethernet0/4/3]port trunk permit vlan ?
INTEGER<1-4094> VLAN ID
all All the VLANs
[H3C1-Ethernet0/4/3]port trunk permit vlan all
Please wait...
%Nov 18 19:59:07:453 2010 H3C1 IFNET/4/LINK UPDOWN:
Vlan-interface2: link status is UP
%Nov 18 19:59:07:453 2010 H3C1 IFNET/4/UPDOWN:
Line protocol on the interface Vlan-interface2 is UP ........................................ Done.
[H3C1-Ethernet0/4/3] //此时vlan2接口就开启了
[H3C2]interface e0/4/3
[H3C2-Ethernet0/4/3]port trunk permit vlan all
Please wait...
%Nov 18 20:00:16:844 2010 H3C2 IFNET/4/LINK UPDOWN:
Vlan-interface2: link status is UP
%Nov 18 20:00:16:844 2010 H3C2 IFNET/4/UPDOWN:
Line protocol on the interface Vlan-interface2 is UP ........................................ Done.
[H3C2-Ethernet0/4/3]
[H3C1]display vlan all
VLAN ID: 1
VLAN Type: static
Route Interface: configured
IP Address: 1.1.1.1
Subnet Mask: 255.255.255.0
Description: VLAN 0001
Broadcast MAX-ratio: 100%
Tagged Ports: none
Untagged Ports:
Ethernet0/4/0 Ethernet0/4/1 Ethernet0/4/2
Ethernet0/4/3 Ethernet0/4/4 Ethernet0/4/5
Ethernet0/4/6 Ethernet0/4/7
VLAN ID: 2
VLAN Type: static
Route Interface: configured
IP Address: 2.2.2.2
Subnet Mask: 255.255.255.0
Description: VLAN 0002
Broadcast MAX-ratio: 100%
Tagged Ports:
Ethernet0/4/3 //本vlan通过哪个接口出去
Untagged Ports: none
[H3C1]display interface e0/4/3
部分显示省略
Port link-type: trunk
VLAN passing : 1(default vlan), 2 //此时通过的vlan
VLAN permitted: 1(default vlan), 2-4094 //此时允许通过的vlan是all
Trunk port encapsulation: IEEE 802.1q
<H3C1>display gvrp statistics
GVRP statistics on port Ethernet0/4/3
GVRP Status : Enabled
GVRP Running : YES
GVRP Failed Registrations : 0
GVRP Last Pdu Origin : 0000-5602-0003
GVRP Registration Type : Normal
二.vlan间路由
1.三层交换--trunk和hybrid
首先介绍trunk
通过trunk使用三层交换实现vlan间路由是很简单的,只需要开启trunk链路并允许相应vlan通过即可!与Cisco不同,不需要开启路由功能!!!!
然后是hybrid
Hybrid是h3c的,下面的实验就是hybrid的应用。
实验拓扑
|
|
实验环境:
Pc0属于vlan2 网关:192.168.2.254
Pc1属于vlan3 网关:192.168.3.254
Sw1上 vlan2:192.168.2.254 sw2上 vlan3:192.168.2.252
Vlan3:192.168.3.252 vlan3:192.168.3.252
实验步骤:
创建vlan并把相应的接口加入到vlan中
[sw1]vlan 2
[sw1-vlan2]vlan 3
[sw1-vlan3]vlan 2
[sw1-vlan2]port e1/0/6
为vlan设置ip地址
开启hybrid的混杂链路类型
设置vlan2、3不打标签!看同一台交换机上不同vlan能否通信
看不同交换机上的不同vlan能否通信
实验环境如图
实验步骤:
创建vlan并把相应的接口加入到vlan中
[sw1]vlan 2
[sw1-vlan2]vlan 3
[sw1-vlan3]vlan 2
[sw1-vlan2]port e1/0/6
[sw1]int e1/0/2
[sw1-Ethernet1/0/2]port link-type trunk
[sw1-Ethernet1/0/2]port trunk permit vlan all
[sw2]vlan 2
[sw2-vlan2]vlan 3
[sw2-vlan3]port e1/0/6
[sw2-Ethernet1/0/2]port link-type trunk
[sw2-Ethernet1/0/2]port trunk p vlan all
为vlan设置ip地址(不设置应该可以)
设置路由器--开启主接口
[H3C]int e0/0
[H3C-Ethernet0/0]un shut
创建子接口-ip-封装类型+对应vid
[H3C]int e0/0.1
[H3C-Ethernet0/0.1]ip add 192.168.2.254 24
[H3C-Ethernet0/0.1]vlan-type dot1q vid 2
[H3C]int e0/0.2
[H3C-Ethernet0/0.2]ip add 192.168.3.254 24
[H3C-Ethernet0/0.2]vlan-type dot1q vid 3
[H3C]display ip int b
*down: administratively down
(s): spoofing
Interface Physical Protocol IP Address
Aux0 down down unassigned
Ethernet0/0 up down unassigned
Ethernet0/0.1 up up 192.168.2.254
Ethernet0/0.2 up up 192.168.3.254
Ethernet0/1 down down unassigned
Serial4/0 down down unassigned
[H3C]int e0/0
[H3C-Ethernet0/0]ip add 192.168.1.1 24
Sw1上开启与路由器相连的trunk链路--允许所有
[sw1]int e1/0/12
[sw1-Ethernet1/0/12]port link-type trunk
[sw1-Ethernet1/0/12]port trunk permit vlan all