实验目的
了解VLAN的作用和配置。
基础实验

需求:所有PC在相同网段,但只有PC1和PC3可以互通,PC2和PC4可以互通
配置思路
将可以互通的PC放到相同的VLAN中即可。
配置过程
某一个switch的配置:
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
#
interface GigabitEthernet0/0/23
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/24
port link-type access
port default vlan 10
在另一个交换机上也进行类似配置,即可实现需求。
配置原理
连接PC机的接口配置为access类型,设置pvid。连接交换机的接口需承载vlan 10 20多个vlan, 配置为trunk类型,并设置允许通过的vlan。
VLAN互通实验
子接口实现

路由器子接口配置:
#
interface GigabitEthernet0/0/0.10
dot1q termination vid 10
ip address 192.168.100.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/0.20
dot1q termination vid 20
ip address 192.168.200.254 255.255.255.0
arp broadcast enable
arp广播从 V200R003C01 及之后版本默认已使能,但我用的ensp版本比较老还需要手动使能
交换机同基础实验配置。
vlanif实现

组网:LSW2作为核心交换机,LSW1作为接入交换机,两者通过三条链路互连,将三条链路作链路聚合。
核心交换机配置:
#
interface Vlanif10
ip address 192.168.100.254 255.255.255.0
#
interface Vlanif20
ip address 192.168.200.254 255.255.255.0
#
interface MEth0/0/1
# 链路聚合
interface Eth-Trunk1
port link-type trunk
port trunk allow-pass vlan 10 20
mode lacp-static
lacp preempt enable
max active-linknumber 2
#
interface GigabitEthernet0/0/1
eth-trunk 1
#
interface GigabitEthernet0/0/2
eth-trunk 1
#
interface GigabitEthernet0/0/3
eth-trunk 1
配置链路聚合只使用两条链路,且配置0/0/1和0/0/2优先级权重高优先使用这两条链路。
[Huawei]display eth-trunk 1
Eth-Trunk1's state information is:
Local:
LAG ID: 1 WorkingMode: STATIC
Preempt Delay Time: 30 Hash arithmetic: According to SIP-XOR-DIP
System Priority: 32768 System ID: 4c1f-cc57-7134
Least Active-linknumber: 1 Max Active-linknumber: 2
Operate status: up Number Of Up Port In Trunk: 2
--------------------------------------------------------------------------------
ActorPortName Status PortType PortPri PortNo PortKey PortState Weight
GigabitEthernet0/0/1 Selected 1GE 32768 2 305 10111100 1
GigabitEthernet0/0/2 Selected 1GE 32768 3 305 10111100 1
GigabitEthernet0/0/3 Unselect 1GE 32768 4 305 10100000 1
Partner:
--------------------------------------------------------------------------------
ActorPortName SysPri SystemID PortPri PortNo PortKey PortState
GigabitEthernet0/0/1 32768 4c1f-cc87-3fb6 100 2 305 10111100
GigabitEthernet0/0/2 32768 4c1f-cc87-3fb6 200 3 305 10111100
GigabitEthernet0/0/3 32768 4c1f-cc87-3fb6 32768 4 305 10100000
核心交换机路由表:
[Huawei]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.100.0/24 Direct 0 0 D 192.168.100.254 Vlanif10
192.168.100.254/32 Direct 0 0 D 127.0.0.1 Vlanif10
192.168.200.0/24 Direct 0 0 D 192.168.200.254 Vlanif20
192.168.200.254/32 Direct 0 0 D 127.0.0.1 Vlanif20
路由过程:主机(192.168.100.1)ping 192.168.200.1时,根据路由表找到下一跳接口为vlanif20, 发给对应的物理接口即聚合后的eth-trunk 1,发送到接入交换机然后传到目的主机。返回过程类似,不再详述。
总结
vlan的目的是划分逻辑子网,缩小广播域。通过基础实验可以了解,在业务需要时vlan之间的互通(三层)也可以实现,参考vlan互通实验。