Configure MAC Address-Based VLANs
Network Requirements
- PC1 and PC2 can access the network through different ports of Device.
- The MAC-address based VLAN functions need to be configured so that the PCs with the specified MAC addresses can access the server through different ports. PCs which do not have a specified MAC address can access the server only through a specified port.
Network Topology
Figure 3-3 Networking for Configuring MAC address-Based VLANs
Configuration Steps
Step 1: On Device, configure VLANs, and configure the port link types of the ports.
On Device, create VLAN2 and VLAN3.
Device#configure terminal
Device(config)#vlan 2-3
|
#On Device2, configure the link type of ports gigabitethernet0/1 and gigabitethernet0/3 to Access and allow services of VLAN2 to pass.
Device(config)#interface gigabitethernet 0/1,0/3
Device(config-if-range)#switchport mode access
Device(config-if-range)#switchport access vlan 2
Device(config-if-range)#exit
|
#On Device, configure the link type of port gigabitethernet0/2 to Hybrid and allow services of VLAN2 and VLAN3 to pass, and set PVID to 3.
Device(config)#interface gigabitethernet 0/2
Device(config-if-gigabitethernet0/2)#switchport mode hybrid
Device(config-if-gigabitethernet0/2)#switchport hybrid untagged vlan 2-3
Device(config-if-gigabitethernet0/2)#switchport hybrid pvid vlan 3
Device(config-if-gigabitethernet0/2)#exit
|
Step 2: Configure the MAC address-based VLAN function.
#On Device, configure an MAC address-based VLAN entry so that the packets with the source MAC address 0001.7a00.0001 can be forwarded in VLAN2.
Device(config)#mac-vlan mac-address 0001.7a00.0001 vlan 2
|
#On port gigabitethernet0/2 of Device, enable the MAC address-based VLAN function.
Device(config)#interface gigabitethernet 0/2
Device(config-if-gigabitethernet0/2)#mac-vlan enable
Device(config-if-gigabitethernet0/2)#exit
|
Step 3: Check the result.
#On Device, query MAC VLAN entries and port enable status.
Device#show mac-vlan
total 1024, used 1, left 1023
--------------------------MAC-VLAN------------------------------------
NO. Mac Address Dynamic Vlan Static Vlan Current Pri Static Pri
-- --------------- ------ ----- ---- ---- ------ --- --------
1 0001.7a00.0001 0 2 ------------------------
---------------------ENABLE MAC-VLAN-------------------------------
gi0/2
#PC1 can access the server through port gigabitethernet0/1 or gigabitethernet0/2, while PC2 can access the server only through port gigabitethernet0/1.