VLAN Usage
A VLAN (Virtual Local Area Network) is a logical subdivision of a physical network that allows devices on different physical LANs to communicate as if they were on the same physical LAN. This segmentation helps to manage traffic efficiently, enhance security, and improve network performance by reducing broadcast domains.
Configuration on Ubuntu
Configuration file is located under the folder: /etc/netplan
# List files in the folder
ls /etc/netplan
# Edit the file
sudo nano 00-installer-config.yaml
Content of the file:
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: true
optional: true
# Add VLAN 30 with IP Adress
vlans:
eth0.30:
id: 30
link: eth0
addresses: [10.3.3.10/24]
version: 2
Explanation
In this configuration we added VLAN 30
on the eth0
interfaces.
eth0.30
: Represents a VLAN with ID 30 created on theeth0
interface.id: 30
: The VLAN ID, a unique identifier for this VLAN.link: eth0
: Indicates that this VLAN is tied to theeth0
physical interface.addresses: [10.3.3.10/24]
: Assigns a static IP address (10.3.3.10
) with a subnet mask (/24
) to the VLAN.
Test and Apply configuration
# Try the configuration before applying
netplan try -timeout 120
# Apply network configuration
netplan apply