摘要
本文取自HCIE R&S实验,引用[HCIE_R_S :: 第9章 :: 第1节 VLAN],如果你需要实验配置文件,请联系ycc_job@163.com。
实验目录
根据MAC地址划分VLAN
基于子网划分VLAN
基于协议划分VLAN
基于策略划分VLAN
VLAN聚合
MUX VLAN
MUX VLAN和VLAN聚合联合
根据MAC地址划分VLAN
实验原理
将MAC地址与VLAN之间建立一个函数映射关系。
网络拓扑

配置代码
#S1 sys sys S1 vlan 10 mac-vlan mac-addr 5489-982B-3468 mac-vlan mac-addr 5489-987A-19BC mac-vlan mac-addr 5489-98C9-3DD3 int e0/0/1 port link-type hybrid port hybrid untagged vlan 10 mac-vlan en int e0/0/2 port link-type hybrid port hybrid untagged vlan 10 mac-vlan en int e0/0/3 port link-type hybrid port hybrid untagged vlan 10 mac-vlan en int g0/0/1 port link-type hybrid port hybrid tagged vlan 10 #S2 sys sys S2 vlan batch 10 int e0/0/1 port link-type acc port default vlan 10 int g0/0/1 port link-type hybrid port hybrid tagged vlan 10
基于子网划分VLAN
实验原理
建立网段(ip_addr, mask)-> vlan之间的映射。
实验拓扑

配置代码
#S1 sys sys S1 vlan 100 ip-subnet-vlan 1 ip 192.168.1.0 24 priority 2 vlan 200 ip-subnet-vlan 1 ip 192.168.2.0 24 priority 3 vlan 300 ip-subnet-vlan 1 ip 192.168.3.0 24 priority 4 int g0/0/1 port link-type hybrid port hybrid untagged vlan 100 200 300 ip-subnet-vlan en int g0/0/2 port link-type trunk port trunk allow-pass vlan 100 200 300 #R1 sys sys R1 vlan batch 100 200 300 int g0/0/1.100 ip addr 192.168.1.254 24 dot1q termination vid 100 int g0/0/1.200 ip addr 192.168.2.254 24 dot1q termination vid 200 int g0/0/1.300 ip addr 192.168.3.254 24 dot1q termination vid 300
基于协议划分VLAN
实验原理
建立数据帧负载协议与VLAN之间的映射,使得特定协议的数据在某个特定的VLAN中传播。
实验拓扑

配置代码
#S1 sys sys S1 vlan 10 protocol-vlan ipv4 vlan 20 protocol-vlan ipv6 #PC1 IPv6 int g0/0/2 protocol-vlan vlan 10 all priority 5 port link-type hybird port hybrid untagged vlan 10 #PC2 IPv4 int g0/0/3 protocol-vlan vlan 20 all priority 6 port link-type hybrid port hybrid untagged vlan 20 int g0/0/1 port link-type trunk port trunk allow-pass vlan 10 20 #Swicth sys sys Swicth vlan batch 10 20 int g0/0/1 port link-type trunk port trunk allow-pass vlan 10 20 int g0/0/2 port link-type trunk port trunk allow-pass vlan 10 int g0/0/3 port link-type trunk port trunk allow-pass vlan 20
基于策略划分VLAN
注释
该实验对应的书面材料中的代码不正确,现已更正并用红字标明。
实验原理
根据MAC地址、IP地址、端口的组合划分VLAN。
实验拓扑

配置代码
#S1 sys sys S1 vlan batch 2 3 int g0/0/1 port link-type hybrid port hybrid untagged vlan 2 int g0/0/2 port link-type hybrid port hybrid untagged vlan 3 int g0/0/3 port link-type trunk port trunk allow-pass vlan 2 3 #创建VLAN2并且绑定MAC地址、IP地址、接口,书中此处配置顺序不正确,并缺少interface关键字。 vlan 2 policy-vlan mac-addr 5489-9850-22E0 ip 192.168.1.1 int g0/0/1 priority 7 #创建VLAN3并且绑定MAC地址、IP地址、接口 vlan 3 policy-vlan mac-addr 5489-98DB-6367 ip 172.16.1.3 int g0/0/2 priority 5 #S2 sys sys S2 vlan batch 2 3 int g0/0/1 port link-type hybrid port hybrid untagged vlan 2 int g0/0/2 port link-type hybrid port hybrid untagged vlan 3 int g0/0/3 port link-type trunk port trunk allow-pass vlan 2 3 #创建VLAN2并且绑定MAC地址、IP地址、接口,错误同上。 vlan 2 policy-vlan mac-addr 5489-9892-495E ip 192.168.1.2 int g0/0/1 priority 7 #创建VLAN3并且绑定MAC地址、IP地址、接口 vlan 3 policy-vlan mac-addr 5489-9856-33EF ip 172.16.1.4 int g0/0/2 priority 5
VLAN聚合
实验拓扑

配置代码
#S1
/**
将相应端口划分到对应VLAN中
**/
sys
sys S1
vlan batch 2 3
int g0/0/1
port link-type acc
port default vlan 2
int g0/0/2
port link-type acc
port default vlan 2
int g0/0/3
port link-type acc
port default vlan 3
int g0/0/4
port link-type acc
port default vlan 3
int g0/0/5
port link-type trunk
port trunk allow-pass vlan 2 3
#S2
sys
sys S2
vlan batch 2 3 4 10
int g0/0/5
port link-type trunk
port trunk allow-pass vlan 2 3
/**
VLAN聚合
**/
vlan 4
aggregate-vlan
access-vlan 2 to 3
int vlanif4
ip addr 10.1.1.1 255.255.255.0
arp-proxy inter-sub-vlan-proxy enable
//和路由器连接的接口
int g0/0/1
port link-type trunk
port trunk allow-pass vlan 10
port trunk pvid vlan 10
int vlanif10
ip addr 10.10.1.1 255.255.255.0
//由路由器传递访问外界的流量
ip route-static 0.0.0.0 0.0.0.0 10.10.1.2
#R1
sys
sys R1
int g0/0/0
ip addr 10.10.1.2 24
ip route-static 10.1.1.0 24 10.10.1.1
MUX VLAN
配置需求
VLAN3中的主机为内部主机,可以互访,但VLAN4中的主机是外部主机不能互访。VLAN3、4都能访问Server。
网络拓扑

配置代码
#S1 sys sys S1 vlan batch 2 3 4 //设置VLAN 2为principal VLAN,VLAN 3 4分别为group separate。 vlan 2 mux-vlan subordinate group 3 subordinate separate 4 int g0/0/1 port link-type acc port def vlan 3 port mux-vlan en int g0/0/2 port link-type acc port def vlan 3 port mux-vlan en int g0/0/3 port link-type acc port def vlan 3 port mux-vlan en int g0/0/4 port link-type acc port def vlan 4 port mux-vlan en int g0/0/5 port link-type acc port def vlan 4 port mux-vlan en
MUX VLAN和VLAN聚合联合
网络拓扑

配置代码
#LSW1
sys
sys S1
vlan batch 2 3 4
vlan 4
mux-vlan
subordinate group 2
subordinate separate 3
int g0/0/1
port link-type acc
port def vlan 2
port mux-vlan en
int g0/0/2
port link-type acc
port def vlan 2
port mux-vlan en
int g0/0/3
port link-type acc
port def vlan 3
port mux-vlan en
int g0/0/4
port link-type acc
port def vlan 3
port mux-vlan en
int g0/0/24
port link-type trunk
port trunk allow-pass vlan 2 3 4
#S2
sys
sys S2
vlan batch 2 3 4
vlan 4
aggregate-vlan
access-vlan 2 3
int g0/0/24
port link-type trunk
port trunk allow-pass vlan 2 3 //根据VLAN聚合的工作机制,这里并不需要通过VLAN 4。
int vlanif4
ip addr 192.168.1.1 24
arp-proxy inter-sub-vlan-proxy en
分割符号
浙公网安备 33010602011771号