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.
-
Create a VLAN interface: This command creates a new VLAN interface named
vlan10on theeth0physical interface with a VLAN ID of 10.sudo nmcli con add type vlan con-name vlan10 ifname vlan10 id 10 dev eth0 -
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 -
Bring up the VLAN interface:
sudo nmcli con up vlan10 -
View the VLAN interface:
ip addr show vlan10