
Discover the convenient and efficient way to change IPv4 addresses on your Linux machine using the nmcli utility, and take control of your network settings
Learn how to set up VLANs using nmcli
on RHEL 9 with this step-by-step guide. Includes CLI examples, troubleshooting tips, and best practices for configuring VLAN interfaces in a Linux environment.
In modern enterprise networks, Virtual LANs (VLANs) are essential for segmenting traffic, improving security, and optimizing performance. On Red Hat Enterprise Linux 9 (RHEL 9), the nmcli
(NetworkManager Command Line Interface) tool makes configuring VLANs fast, efficient, and scriptable—ideal for sysadmins and DevOps teams managing scalable infrastructure.
This tutorial walks you through the steps to set up VLANs using nmcli
on RHEL 9, with real-world examples and best practices.
A Virtual LAN (VLAN) is a logical subdivision of a Layer 2 network that allows devices to communicate as if they were on the same physical LAN—even when separated. VLANs help:
|
|
|
|
VLANs are identified by VLAN IDs, which range from 1 to 4094.
Red Hat Enterprise Linux 9 uses NetworkManager to manage network interfaces. While tools like nmtui
(TUI) and nm-connection-editor
(GUI) are available, nmcli is preferred for:
|
|
|
|
Before proceeding, ensure the following requirements are met:
Requirement | Description |
---|---|
Operating System | RHEL 9 or compatible (e.g., CentOS Stream 9, AlmaLinux) |
Root Privileges | Required to configure network settings |
NetworkManager | Must be installed and running |
To check if NetworkManager is active:
sudo systemctl status NetworkManager
If not running, start and enable it:
sudo systemctl enable --now NetworkManager
Let’s configure a VLAN on a server with one physical interface (e.g., ens33
) using VLAN ID 100 and IP address 192.168.100.10/24.
🔄 Step 1: Identify Your Parent Interface |
List available network interfaces:
nmcli device status
Example output:
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
lo loopback unmanaged --
In this case, ens33
is the parent interface.
🔄 Step 2: Create the VLAN Interface |
Create a VLAN interface named vlan100
on ens33
with VLAN ID 100:
sudo nmcli connection add type vlan con-name vlan100 dev ens33 id 100
This command:
|
|
|
🔄 Step 3: Assign an IP Address |
sudo nmcli connection modify vlan100 ipv4.addresses 192.168.100.10/24
sudo nmcli connection modify vlan100 ipv4.gateway 192.168.100.1
sudo nmcli connection modify vlan100 ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli connection modify vlan100 ipv4.method manual
sudo nmcli connection modify vlan100 ipv4.method auto
🔄 Step 4: Activate the VLAN Interface |
Bring up the new VLAN interface:
sudo nmcli connection up vlan100
Expected output:
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
Verify the interface:
ip a show vlan100
Check the connection status and settings:
nmcli device show vlan100
nmcli connection show vlan100
Sample output:
connection.id: vlan100
connection.interface-name: vlan100
connection.type: vlan
vlan.parent: ens33
vlan.id: 100
ipv4.addresses: 192.168.100.10/24
Test connectivity:
ping -c 4 192.168.100.1
Changes made using nmcli connection
are persistent by default. To list all persistent connections:
nmcli connection show
To disable or remove the VLAN:
sudo nmcli connection down vlan100
sudo nmcli connection delete vlan100
Issue | Solution |
---|---|
VLAN interface not appearing | Ensure the parent interface (ens33 ) is up and managed |
Cannot ping gateway | Check VLAN tagging and switch port configuration |
IP not assigned | Verify static or DHCP settings |
Interface not managed | Run: nmcli device set <interface> managed yes |
Duplicate VLAN ID | Ensure VLAN IDs are unique per parent interface |
For deeper debugging:
journalctl -xeu NetworkManager
nmcli general logging level DEBUG domains ALL
To secure your VLAN deployment:
|
|
|
|
|
Setting up VLANs with nmcli
on RHEL 9 is a powerful way to manage network segmentation—without relying on GUIs or third-party tools. Whether you’re automating environments, enhancing security, or managing large infrastructures, VLANs are a foundational tool in modern Linux networking.
By following the steps in this guide, you can confidently deploy secure and scalable VLAN configurations using only the command line.
Did you find this article helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit, and let us know your thoughts in the comments section below.
Discover the convenient and efficient way to change IPv4 addresses on your Linux machine using the nmcli utility, and take control of your network settings
Learn how to easily convert your IP address from DHCP to static using NMCLI. Follow our step-by-step guide for seamless configuration on Linux systems. Table
In this article, we’ll show you how to quickly add multiple IP addresses using NMCLI, a powerful command-line tool for configuring network settings on RHEL8/9