Configuring 802.1Q Trunking

Nerd Cafe

Scenario:

You have two Cisco switches, Switch1 and Switch2, and you want to set up an 802.1Q trunk between them. The trunk will carry traffic for multiple VLANs (for example, VLAN 10, VLAN 20, and VLAN 30) between the two switches.

The goal is for devices on different VLANs on different switches to communicate as if they are on the same network.

Network Topology:

Topology

Sw1 and Sw2 are connected via a trunk link, which is configured on their respective interfaces.

Step-by-Step Guide to Configuring 802.1Q Trunking:

Step 1: Initial Setup on Switch1

Access Switch1:

  • Open the command-line interface (CLI) of Sw1 using a console cable or SSH (if configured).

Configure VLANs on Switch1:

  • Define the VLANs that will be used on both switches. In this case, we are using VLAN 10, VLAN 20, and VLAN 30.

Sw1#configure terminal
Sw1(config)#vlan 10
Sw1(config-vlan)#name Marketing
Sw1(config-vlan)#exit
Sw1(config)#vlan 20
Sw1(config-vlan)#name HR
Sw1(config-vlan)#exit
Sw1(config)#vlan 30
Sw1(config-vlan)#name IT

Configure the trunk port:

  • Let's say the trunk port on Switch1 will be FastEthernet 0/1.

  • Enter interface configuration mode and set it as a trunk port.

Sw1(config)#interface ethernet 3/3
Sw1(config-if)#switchport trunk encapsulation dot1q
Sw1(config-if)#switchport mode trunk

Verify the configuration:

  • Use the following command to verify that the trunk is correctly configured.

Sw1#show interfaces ethernet 3/3 switchport
Name: Et3/3
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk Native VLAN tagging: enabled
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk associations: none
Administrative private-vlan trunk mappings: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL

Protected: false
Appliance trust: none
Sw1#

Step 2: Initial Setup on Switch2

Access Switch2:

  • Access the command-line interface (CLI) of Switch2.

Configure VLANs on Switch2:

  • Just like on Switch1, configure the same VLANs on Switch2.

Sw2#configure terminal
Sw2(config)#vlan 10
Sw2(config-vlan)#name Marketing
Sw2(config-vlan)#exit
Sw2(config)#vlan 20
Sw2(config-vlan)#name HR
Sw2(config-vlan)#exit
Sw2(config)#vlan 30
Sw2(config-vlan)#name IT

Configure the trunk port:

  • Configure the trunk port on FastEthernet 0/1 on Switch2 (the same port used on Switch1).

Sw2(config)#interface ethernet 3/3
Sw2(config-if)#switchport trunk encapsulation dot1q
Sw2(config-if)#switchport mode trunk

Verify the configuration:

  • Again, verify that the trunk is working correctly.

Sw2#show interfaces ethernet 3/3 switchport
Name: Et3/3
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk Native VLAN tagging: enabled
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk associations: none
Administrative private-vlan trunk mappings: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL

Protected: false
Appliance trust: none
Sw2#

Step 3: Verify Connectivity Between VLANs

Assign VLANs to Access Ports:

  • Now, you need to assign VLANs to the access ports on both switches so that devices in different VLANs can communicate.

On Sw1:

Sw1#configure terminal
Sw1(config)#interface range ethernet 0/0-3
Sw1(config-if-range)#switchport mode access
Sw1(config-if-range)#switchport access vlan 10
Sw1(config-if-range)#exit
Sw1(config)#interface range ethernet 1/0-3
Sw1(config-if-range)#switchport mode access
Sw1(config-if-range)#switchport access vlan 20
Sw1(config-if-range)#exit
Sw1(config)#interface range ethernet 2/0-3
Sw1(config-if-range)#switchport mode access
Sw1(config-if-range)#switchport access vlan 30

On Sw2:

Sw2#configure terminal
Sw2(config)#interface range ethernet 0/0-3
Sw2(config-if-range)#switchport mode access
Sw2(config-if-range)#switchport access vlan 10
Sw2(config-if-range)#exit
Sw2(config)#interface range ethernet 1/0-3
Sw2(config-if-range)#switchport mode access
Sw2(config-if-range)#switchport access vlan 20
Sw2(config-if-range)#exit
Sw2(config)#interface range ethernet 2/0-3
Sw2(config-if-range)#switchport mode access
Sw2(config-if-range)#switchport access vlan 30

Check the Trunk Link:

  • Verify that the trunk link is allowing multiple VLANs to pass by using the show vlan brief command. The trunk should be carrying VLANs 10, 20, and 30.

On Sw1:

Sw1#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Et3/0, Et3/1, Et3/2
10   Marketing                        active    Et0/0, Et0/1, Et0/2, Et0/3
20   HR                               active    Et1/0, Et1/1, Et1/2, Et1/3
30   IT                               active    Et2/0, Et2/1, Et2/2, Et2/3
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup

On Sw2:

Sw2#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Et3/0, Et3/1, Et3/2
10   Marketing                        active    Et0/0, Et0/1, Et0/2, Et0/3
20   HR                               active    Et1/0, Et1/1, Et1/2, Et1/3
30   IT                               active    Et2/0, Et2/1, Et2/2, Et2/3
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup

Step 4: Testing the Configuration

Test Connectivity:

  • Connect devices to the access ports on each switch and test that they can communicate across the VLANs.

  • For example, if you have a device on VLAN 10 connected to Sw1, you should be able to ping the device on VLAN 10 connected to Sw2.

/PC1> ping 192.168.10.101

84 bytes from 192.168.10.101 icmp_seq=1 ttl=64 time=0.703 ms
84 bytes from 192.168.10.101 icmp_seq=2 ttl=64 time=1.084 ms
84 bytes from 192.168.10.101 icmp_seq=3 ttl=64 time=0.810 ms
84 bytes from 192.168.10.101 icmp_seq=4 ttl=64 time=1.055 ms
^C
PC1>

Keywords

802.1Q trunking, VLAN trunking, Cisco switch configuration, trunk port, VLAN tagging, switchport mode trunk, dot1q encapsulation, inter-switch communication, VLAN propagation, trunk link, Cisco CCNA, switchport access vlan, show interfaces trunk, VLAN management, switch configuration, network segmentation, access port, trunking protocol, Ethernet trunk, switch-to-switch connection, سیسکو

Last updated