Skip to main content

VLAN & Switching

VLANs (Virtual LANs) are a way to logically segment a network into multiple broadcast domains.

VLAN Tagging, Trunk, and Access Ports

  • VLAN Tagging (IEEE 802.1Q): A method of inserting a VLAN tag into an Ethernet frame to identify the VLAN to which the frame belongs.
  • Trunk Port: A trunk port is a port on a switch that is configured to carry traffic for multiple VLANs. Trunk ports use VLAN tagging to differentiate between the traffic from different VLANs.
  • Access Port: An access port is a port on a switch that is assigned to a single VLAN. Traffic on an access port is untagged.

nmcli connection add type vlan examples

You can use the nmcli command to create and manage VLAN interfaces in Linux.

  1. Create a VLAN interface: This command creates a new VLAN interface named vlan10 on the eth0 physical interface with a VLAN ID of 10.

    sudo nmcli con add type vlan con-name vlan10 ifname vlan10 id 10 dev eth0
  2. Assign an IP address to the VLAN interface:

    sudo nmcli con mod vlan10 ipv4.addresses 192.168.10.10/24
    sudo nmcli con mod vlan10 ipv4.method manual
  3. Bring up the VLAN interface:

    sudo nmcli con up vlan10
  4. View the VLAN interface:

    ip addr show vlan10