跳转到内容
Ask AI

VLAN Configuration Guide

此内容尚不支持你的语言。

Although using devices to interconnect Local Area Networks (LANs) can mitigate collision problems, it still fails to isolate broadcast messages and enhance network quality. In response to these challenges, Virtual Local Area Network (VLAN) technology emerged. VLAN logically divides a physical LAN into multiple broadcast domains, allowing direct communication between hosts within the same VLAN while preventing direct communication between different VLANs. This containment of broadcast messages within their respective VLANs improves network isolation and performance.

Different types of interfaces on a device handle VLAN tagging differently when forwarding packets. Based on their VLAN tagging behavior, interfaces can be categorized into three types: Access, Trunk, and Hybrid interfaces.

Access Interface

This interface adds the interface’s Port VLAN ID (PVID) to untagged incoming packets.

It only allows tagged packets with VLAN IDs matching the interface’s PVID to pass through.

Outgoing packets from this interface are always untagged, making it suitable for connecting user terminals.

Trunk Interface

It permits multiple VLAN tags to pass through.

Outgoing packets from this interface have no VLAN tag if their VLAN matches the interface’s default VLAN. Other VLANs must have a VLAN tag. Trunk interfaces are often used for interconnecting network transmission equipment.

Hybrid Interface

This interface type is not supported by the current device and is not further described.

In addition to configuring the VLANs allowed to traverse a port, you can also define a default VLAN for the port, known as the Port VLAN ID (PVID). When an untagged packet is received on the port, it is assumed to belong to the default VLAN.

For Access ports, the default VLAN corresponds to the VLAN the interface has been configured to join in access mode.

Interface TypeIngressEgress
AccessUntagTag
Adding Default VLAN ID of the interfaceWhen the VLAN ID of a packet matches the default VLAN ID of the interface, the interface receives the packet.When the VLAN ID of a packet matches the interface’s default VLAN ID, the interface removes the tag and sends the packet.
When the VLAN ID of a packet differs from the interface’s default VLAN ID and the packet’s VLAN ID is one of the VLAN IDs allowed through the interface: the original tag is preserved, and the packet is sent
TrunkAdding Default VLAN ID of the interfaceWhen the VLAN ID of a packet is in the list of VLAN IDs allowed through the interface, the packet is received.
When the VLAN ID of a packet is not in the list of VLAN IDs allowed through the interface, the packet is discarded.
The VLAN tag of the packet remains unchanged.
OperationCommandDescription
Enter the system configuration viewconfigure terminal
Create a VLANvlan ID
Enter the interface viewinterface ethernet ID
Assign an access VLANswitchport access vlan ID
Assign a trunk VLANswitchport trunk vlan ID
Remove a VLANno switchport vlan ID
OperationCommandDescription
Display VLAN summary informationshow vlan summary
Display detailed information about a specific VLANshow vlan vid vlan-id
Display information for all VLANsshow vlan all

Configuring VLAN Assignment Based on Interfaces for Intra-VLAN Communication

Section titled “Configuring VLAN Assignment Based on Interfaces for Intra-VLAN Communication”

Network requirements

Suppose User 1 and User 3 of a company belong to the same department but access the network through different devices, User 2 and User 4 belong to the same department and access the network through different devices but belong to different VLANs, where Department A uses VLAN 100 and Department B uses VLAN 200.

Procedure

1.Configure Device A

# Create VLAN and add the interface to the VLAN

sonic(config)# vlan 100
sonic(config)# vlan 200
sonic(config)# interface ethernet 1
sonic(config-if-1)# switchport access vlan 200
sonic(config)# interface ethernet 2
sonic(config-if-2)# switchport access vlan 100
sonic(config)# interface ethernet 3
sonic(config-if-3)# switchport trunk vlan 100
sonic(config-if-3)# switchport trunk vlan 200

2.Device B and DeviceA configuration is the same

Verify configuration

1.User 1 and User 3 can ping each other, but neither can ping User 2 and User 4, and User 2 and User 4 can ping each other, but not User 1 and User 3.

2.View VLAN configuration information.

sonic# show vlan summary