MAC address table & VLAN configuration
Now that you know how to log into a Cisco switch CLI and navigate Cisco IOS, we can focus on configuring a few key protocols from Chapter 2 - specifically VLANs and trunking - and then verifying that those configurations are working.
How to view the MAC address table
A good first check on a switch is the MAC address table. It tells you whether the switch is learning MAC addresses from connected devices, and which interface and VLAN each MAC address is associated with.
The command to view the MAC address table is:
show mac address-table
(then press Enter)
(Image 084)
Image Title - Output of a SW1s MAC Address Table
In the output, you can see that endpoints are connected to GigabitEthernet 0/1 and GigabitEthernet 0/2 on SW1 because the switch is learning their MAC addresses.
You can also see:
- The ports are currently in VLAN 1 (the default VLAN), which means GigabitEthernet 0/1 and 0/2 are still using their default VLAN settings.
MAC addresses can be displayed in various distinct formats. Up until this point you have been exposed to MAC addresses using a double colon (:) as a delimiter. For example:
52:54:00:E8:59:3D
But on Cisco devices (routers and switches), MAC addresses are written with a period (.) as a delimiter:
5254.00e8.593d
This one is the most important to be familiar with, as you will be seeing them a lot on Cisco switches. You may also see MAC addresses displayed with a hyphen (-) as a delimiter, like on Windows computers:
52-54-00-E8-59-3D
These all refer to the same MAC address, just a different format to display them.
If SW1 doesn’t receive another frame from one of those hosts for 300 seconds (5 minutes), it removes that MAC address entry from the MAC table.
In order to view the configured “age” timer for each MAC address entry, you would enter the following command:
show mac address-table aging-time
(Image)
MAC Table Aging Timer
Now that we can see SW1 is learning MAC addresses, let’s place the two hosts into VLAN 2.
Configuring and verifying VLANs
Next, we’ll configure a VLAN and move switchports into it.
If we wanted to place the two hosts into VLAN 2, what are the two steps that we must do on SW1 in order to make that happen?
- Create VLAN 2 on SW1
- Move GigabitEthernet 0/1 and GigabitEthernet 0/2 into VLAN 2
Before creating VLAN 2, check the VLAN database on SW1. This shows which VLANs exist and which ports belong to each VLAN.
Use:
show vlan
(Image 085)
Image Title - Output of a SW1s VLAN database
As shown in the output, only the default VLAN (VLAN 1) exists, and all interfaces on SW1 are currently members of VLAN 1.
You’ll also see Reserved VLANs (1002 - 1005), which are not supported in Ethernet-based Networks.
In order to create VLAN 2, which mode do we have to go into first?
Global Configuration mode
Enter global configuration mode:
configure terminal
Then create VLAN 2:
vlan 2
and press Enter.
For example:
SW1(config)#vlan 2
Every time you type in a command in Cisco IOS, you must hit the enter key in order for the Switch or Router to process the command.
After you create the VLAN, IOS places you into a sub-configuration mode called VLAN configuration mode. You’ll see the prompt change to:
SW1(config-vlan)#
From here, you can optionally name the VLAN (a name isn’t required for the VLAN to function).
For example:
SW1(config-vlan)# name DATA-VLAN
This replaces the default, auto-generated VLAN name with a more descriptive one.
The key thing to note here is that; VLAN configuration changes do not take effect until you exit out of the VLAN Configuration sub-configuration mode. So to do that, we simply must type in:
exit
which will take us back to the Global Configuration mode.
(Image 086)
Image Title - Creating VLAN 2 on SW1 and giving it a name
If you ever need to undo a configuration command, (perhaps you entered it by mistake, or you entered in the wrong value by accident), you can simply negate the command by typing “no” in front of the same configuration that you previously entered. For example, if you wanted to delete vlan 2 for any reason, in Global Configuration mode, you would type in:
SW1(config)# no vlan 2
And hit the enter key. Typing in “no” in front of a configuration command essentially removes (undoes) the command after it was entered. It’s sort of like hitting the “undo” button in a document editor like Microsoft Word. This works with most configuration commands.
Run “show vlan” again to verify that VLAN 2 exists and has the name you assigned:
(Image 087)
Image Title - Verifying the creation of VLAN 2 on SW1
Moving switchports into VLAN 2
Now move GigabitEthernet 0/1 and GigabitEthernet 0/2 into VLAN 2.
Start by entering interface configuration mode for GigabitEthernet 0/1:
interface gigabitethernet 0/1
(Image 088)
Image Title - Entering the Interface Configuration mode for the GigabitEthernet 0/1 interface
At this point, the goal is to make GigabitEthernet 0/1 an access port (a port that belongs to a single VLAN) and then assign it to VLAN 2.
First, set the port to access mode:
switchport mode access
(Image 089)
Image Title - Making interface GigabitEthernet 0/1 an Access port.
Then assign it to VLAN 2:
switchport access vlan 2
(Image 090)
Image Title - Moving interface GigabitEthernet 0/1 into VLAN 2.
Verify the change with:
show vlan
(Image 090)
Image Title - show vlan output verifying that GigabitEthernet 0/1 is now in VLAN 2
Next, type exit to return to global configuration mode, and repeat the same steps for GigabitEthernet 0/2.
The sequence of commands is:
SW1(config)#interface gigabitethernet 0/2 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 2
(Image 091)
Image Title - Moving interface GigabitEthernet 0/2 into VLAN 2.
Now when you check the VLAN database, both GigabitEthernet 0/1 and GigabitEthernet 0/2 should appear as members of VLAN 2:
(Image 092)
Image Title - show vlan output verifying that both GigabitEthernet 0/1 and GigabitEthernet0/2 are now in VLAN 2
Checking the MAC address table after the VLAN change
Now check the MAC address table again. You should see the hosts connected to GigabitEthernet 0/1 and GigabitEthernet 0/2 being learned in VLAN 2.
(Image 093)
Image Title - hosts connected to GigabEthernet0/1 and GigabitEthernet0/2 being learned in VLAN 2 in the MAC Table.
If you need to review the underlying concepts, refer back to Chapter 2.2.2 Address Resolution Protocol (ARP) and Ethernet Switching, Chapter 2.3 VLANs and Trunking, and Chapter 2.5.1 Introduction to Cisco’s Internetworking Operating System (IOS).