Config Lab: Trunking for Only Some VLANs

Wendell Odom
By Wendell Odom September 3, 2021 19:05

VLAN trunks between Cisco Catalyst switches support all VLANs known to the switches. As time progresses, each time the switch learns of a new VLAN, the VLAN trunk also allows traffic in the VLAN to use the trunk. Is that a good idea? In this post, you will get a chance to practice those tasks – first to configure ports into VLANs and directly control the VLANs allowed on a VLAN trunk. As a result, traffic for newly-added VLANs does not cross the trunk until you specifically configure the trunk to allow the new VLANs.

All about Config Labs

The blog has a series of lab exercises called “Config Labs.” Each lab presents a topology with the relevant initial configuration for each device. The lab also lists new requirements, after which you should create the additional configuration to meet those requirements. You can do the lab on paper, in a text editor, or use software tools like Cisco Packet Tracer or Cisco Modeling Labs.

Once you have created your answer, you can click various tabs at the bottom of this post to see the lab answers, comments about the lab, and other helpful information.

The Lab Exercise

Requirements

Your job: Configure appropriate interfaces as trunks to pass traffic between PCs while supporting those VLANs only.

This lab begins with all the interfaces shown in Figure 1 working because the cables have been connected, and the switches default to bring up the interfaces. However, you need to add the correct interfaces into the VLANs shown in the figure. Additionally, you must decide what commands to add to make sure the link between the switches trunks and that the link does not depend on any trunking negotiation. Finally, you must ensure that the trunk supports only the two VLANs show in the figure (plus the native VLAN) until someone else comes back to change the configuration.

The specific rules for this lab are:

  • Configure the interfaces connected to PCs to be access interfaces in the correct VLAN.
  • Configure the link between switches to statically act as a trunk (do not rely on trunk negotiation).
  • Configure to restrict the trunk to support only the native VLAN and the other VLANs shown in the figure.
  • Do not configure settings not needed for this lab.

Figure 1: Two Switches – Point-to-Point

 

Initial Configuration

The two switches begin with default configuration and a hostname. The two examples here emphasize that point, confirming that the ports are enabled (no shutdown).

Example 1: SW1 Config

 

Example 2: SW2 Config

Answer Options - Click Tabs to Reveal

You can learn a lot and strengthen real learning of the topics by creating the configuration – even without a router or switch CLI. In fact, these labs were originally built to be used solely as a paper exercise!

To answer, just think about the lab. Refer to your primary learning material for CCNA, your notes, and create the configuration on paper or in a text editor. Then check your answer versus the answer post, which is linked at the bottom of the lab, just above the comments section.

You can also implement the lab using the Cisco Packet Tracer network simulator. With this option, you use Cisco’s free Packet Tracer simulator. You open a file that begins with the initial configuration already loaded. Then you implement your configuration and test to determine if it met the requirements of the lab.

(Use this link for more information about Cisco Packet Tracer.)

Use this workflow to do the labs in Cisco Packet Tracer:

  1. Download the .pkt file linked below.
  2. Open the .pkt file, creating a working lab with the same topology and interfaces as the lab exercise.
  3. Add your planned configuration to the lab.
  4. Test the configuration using some of the suggestions below.

Download this lab’s Packet Tracer File

You can also implement the lab using Cisco Modeling Labs – Personal (CML-P). CML-P (or simply CML) replaced Cisco Virtual Internet Routing Lab (VIRL) software in 2020, in effect serving as VIRL Version 2.

If you prefer to use CML, use a similar workflow as you would use if using Cisco Packet Tracer, as follows:

  1. Download the CML file (filetype .yaml) linked below.
  2. Import the lab’s CML file into CML and then start the lab.
  3. Compare the lab topology and interface IDs to this lab, as they may differ (more detail below).
  4. Add your planned configuration to the lab.
  5. Test the configuration using some of the suggestions below.

Download this lab’s CML file!

 

Network Device Info:

Device Lab Port  CML Port
SW1 G1/0/1 G0/1
SW1 G1/0/2 G0/2
SW1 G1/0/3 G0/3
SW2 G1/0/1 G0/1
SW2 G1/0/2 G0/2
SW2 G1/0/3 G0/3

 

 

Initial Trunking Config Change for CML

The switches need one additional command to be correct at the initial starting point. CML uses an IOS image for Layer 2 switches that requires that the type of trunking be configured. The command added to both switches G0/3 interfaces, which is already added to the .YAML file, is:

Many switches, like the 2960 access switches many people use for CCNA labbing at home, would not require this extra command.

Lab Answers Below: Spoiler Alert

Lab Answers: Configuration (Click Tab to Reveal)

Answers

Figure 1: Two Switches – Point-to-Point

 

Example 3: SW1 Config

 

Example 4: SW2 Config

Commentary, Issues, and Verification Tips (Click Tabs to Reveal)

Commentary

The VLAN configuration follows a straightforward and familiar pattern. In this case, however, the configuration in the suggested answers happens to omit any vlan vlan-id global commands. In each switch, the first time the switchport access vlan vlan-id global command identifies a new VLAN not formerly known by the switch, the switch automatically adds the matching vlan vlan-id global command.

A VLAN trunk forwards traffic from multiple VLANs at the same time. Most switches created since the mid-2000’s use IEEE 802.1Q for the trunking protocol, with most switches today no longer even supporting the older ISL trunking protocol. With 802.1Q, with a default native VLAN setting, Ethernet frames from all VLANs except for VLAN 1 (the default native VLAN) will have an additional tag added to the frame while being forwarded over the VLAN trunk. This tag is essentially a label that marks traffic with its respective VLAN. Once the traffic reaches the second device, that device can strip the tag off and use the information in it to properly forward the traffic.

Cisco Catalyst switches default their administrative trunking setting to a mode that tells the switch to use the Dynamic Trunking Protocol (DTP) to negotiate whether to operate as a trunk or not. The instructions told us statically set trunking rather than dynamically negotiate trunking.  To do that, a simple config is needed on both switches: the switchport mode trunk command is used on both switches. Both happen to connect to each other with their G1/0/3 interfaces.

Trunks support all defined VLANs by default. To achieve that final requirement of disallowing any new VLANs, at least until additional configuration is added, you could remove all the other VLANs from the trunk besides VLANs 100, 200, and the (default) native VLAN 1. The sample answers use the switchport trunk allowed vlan remove 2-99,101-199,200-4094 interface subcommand to do so, which removes all VLANs except 1, 100, and 200 from the list of VLANs from 1 through 4094. Alternately, you could directly define the VLANs using the switchport trunk allowed vlan 1,100,200 interface subcommand.

Finally, depending on how you read the requirements, you might have added the switchport nonegotiate command to the access ports (G1/0/1 and G1/0/2 on each switch) in addition to the trunk ports (G1/0/3 on each switch.) Switches disable DTP if you configure the switchport mode access command, but not on ports with the switchport mode trunk command configured. To be doubly sure, you could just use the switchport nonegotiate command on each port.

Known Issues in this Lab

This section of each Config Lab Answers post hopes to help with those issues by listing any known issues with Packet Tracer related to this lab. In this case, the issues are:

 

# Summary Detail
1 Switch trunks must know the trunking protocol. Packet Tracer LAN switches operate like older Cisco switch generations in that they support both ISL and 802.1Q trunking. To make a trunk work in this lab, you may need to configure the switchport trunk encapsulation dot1q command on each switch interface. Depending on the PT version and switch model used in PT, you may not need the command.
2 PT supports fewer switchport trunk allowed parameters This lab suggests removing VLANs from the trunks, but Packet Tracer LAN switches do not support the related command, as seen in the answer section. Instead, if using PT, use the switchport trunk allowed vlan <list> command, where <list> is the list of VLANs to allow.

 

Why Would Cisco Packet Tracer Have Issues?

(Note: The below text is the same in every Config Lab.)

Cisco Packet Tracer (CPT) simulates Cisco routers and switches. However, CPT does not run the same software as real Cisco routers and switches. Instead, developers wrote CPT to predict the output a real router or switch would display given the same topology and configuration – but without performing all the same tasks, an actual device has to do. On a positive note, CPT requires far less CPU and RAM than a lab full of devices so that you can run CPT on your computer as an app. In addition, simulators like CPT help you learn about the Cisco router/switch user interface – the Command Line Interface (CLI) – without owning real devices.

CPT can have issues compared to real devices because CPT does not run the same software as Cisco devices. CPT does not support all commands or parameters of a command. CPT may supply output from a command that differs in some ways from what an actual device would give. Those differences can be a problem for anyone learning networking technology because you may not have experience with that technology on real gear – so you may not notice the differences. So this section lists differences and issues that we have seen when using CPT to do this lab.

Beyond comparing your answers to this lab’s Answers post, you can test in Cisco Packet Tracer (CPT) or Cisco Modeling Labs (CML). In fact, you can and should explore the lab once configured. For this lab, once you have completed the configuration, try these verification steps. 

  1. Test with IP pings once you complete the PC configurations as follows:
    1. Create configuration on PC1 and PC3 to place them in the same subnet.
    2. Ping PC3’s address from PC1, and vice versa. If the ping works, the traffic must have crossed the trunk in VLAN 100.
    3. Likewise, configure PC2 and PC4 with IP addresses in a second subnet.
    4. Ping PC4’s address from PC2, and vice versa. If the ping works, the traffic must have crossed the trunk in VLAN 200.
  2. Note that because this lab uses no routers or layer 3 switches, once working, the PCs in the same VLAN should be able to ping each other, but they should not be able to ping PCs in other VLANs.
  3. To test the restriction to support only VLANs 100 and 200:
    1. Reconfigure the switches to put the PC1 and PC3 ports into a new VLAN (300).
    2. Again ping PC3 from PC1; the ping should now fail because the trunk does not forward VLAN 300 traffic.
    3. Reconfigure the trunk to allow VLAN 300.
    4. Repeat the ping test, which should now work.

More Labs with Related Content!

Config Lab: Basic VLANs
Config Lab: RSTP Config 1
Wendell Odom
By Wendell Odom September 3, 2021 19:05
Write a comment

4 Comments

  1. almeidajoaodealmeida January 1, 12:05

    Hi Mr Odom, instead of configuring “switchport trunk allowed vlan remove 2-99,101-199,201-4094”, could it be valid to configure “switchport trunk allowed vlan 100,200” ?

    Reply to this comment
    • certskills January 24, 17:29

      Almeida,
      Yes indeed. Even if the “remove” command worked like real switches, IOS would have morphed into into the command without “remove”, listing only the included VLANs.

      Reply to this comment
  2. Branden January 23, 21:10

    Good question also I cant get that last command to work. It just tells me its wrong.

    SW1(config-if)#switchport trunk allowed vlan remove 2-99,101-199,201-4094
    ^
    % Invalid input detected at ‘^’ marker.

    Reply to this comment
    • certskills January 24, 17:30

      Branden,
      I don’t catch all PT issues ahead of time, but this one is noted in the “Packet Tracer Issues” tab. The rejected command is due to PT not supporting the command. If you want to do the lab in PT, you’ll need to think about an alternative, like using a version of the command without the “remove” option (which seems to work better in PT.)

      Reply to this comment
View comments

Write a comment

Comment; Identify w/ Social Media or Email

Subscribe

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Search

Categories