Configuration Guide
VLAN Configuration Guide
9 min
introduction introduction ethernet is a data network communication technology based on csma/cd (carrier sense multiple access/collision detection), which utilizes a shared communication medium when the number of hosts increases, it can lead to severe issues like collisions, broadcast storms, performance degradation, and even network unavailability 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 explanation of principles explanation of principles interface type interface type 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 interface default vlan interface default vlan 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 packet transmission and reception rules packet transmission and reception rules interface type ingress egress access untag tag adding default vlan id of the interface when 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 trunk adding default vlan id of the interface when 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 configuring interface vlan configuring interface vlan operation command description enter the system configuration view configure terminal create a vlan vlan id enter the interface view interface ethernet id assign an access vlan switchport access vlan id assign a trunk vlan switchport trunk vlan id remove a vlan no switchport vlan id display and maintenance display and maintenance operation command description display vlan summary information show vlan summary display detailed information about a specific vlan show vlan vid vlan id display information for all vlans show vlan all configuration example configuration example configuring vlan assignment based on interfaces for intra vlan communication 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
