[SOLVED] Assign multiple VLAN (IP) to a virtual machine

sharbich

Member
Nov 7, 2024
43
1
8
Hello,
how can I assign multiple VLAN (IP) addresses in my VM?
/etc/network/interfaces
Code:
auto lo
iface lo inet loopback

auto enp12s0
iface enp12s0 inet manual

auto enp13s0
iface enp13s0 inet manual

auto enp14s0
iface enp14s0 inet manual

auto enp15s0
iface enp15s0 inet manual

iface ens6f0 inet manual

iface ens6f1 inet manual

auto bond0
iface bond0 inet manual
    bond-slaves enp12s0 enp13s0 enp14s0 enp15s0
    bond-miimon 100
    bond-mode 802.3ad
    bond-xmit-hash-policy layer2
#psme02 bond

auto vmbr0
iface vmbr0 inet static
    address 192.168.20.22/24
    gateway 192.168.20.1
    bridge-ports bond0
    bridge-stp off
    bridge-fd 0
    bridge-vlan-aware yes
    bridge-vids 2-4094

auto vmbr0.200
iface vmbr0.200 inet static
    address 192.168.200.22/24

source /etc/network/interfaces.d/*
Proxmox GUI Version 9:
 

Attachments

  • 2025_09_19_Proxmox-VM-VLAN.png
    2025_09_19_Proxmox-VM-VLAN.png
    126 KB · Views: 11
make sure your vmbr0 bridge is vlan aware - add it to the vm - make the vlan interfaces in the VM operating system.. ;-)
 
The virtual machine "102" is only assigned an IP address from VLAN 140. Not from VLAN 200.
However, the Proxmox host psme02 gets an IP from VLAN 200. Just not the VM 102.
 

Attachments

  • 2025_09_19_Proxmox-Host-Bridge.png
    2025_09_19_Proxmox-Host-Bridge.png
    138.3 KB · Views: 4
  • 2025_09_19_Proxmox-VM-VLAN.png
    2025_09_19_Proxmox-VM-VLAN.png
    131.5 KB · Views: 4
Last edited:
The virtual machine "102" is only assigned an IP address from VLAN 140. Not from VLAN 200.
However, the Proxmox host psme02 gets an IP from VLAN 200. Just not the VM 102.
I'm not entirely sure if you understood the mechanics of networking in Proxmox or Linux in general.
@ce3rd already had an idea fitting your request that you attach a vlan-aware bridge to your vm and create all vlan-interfaces (with multiple ips as you asked for) inside your vm. This way you just need to attach one bridge to the VM.
You can also attach multiple network adapters using the same VLAN-Tag and assign the IPs in the VM like that. But that would be inconvenient IMHO. Depends on your network design.
 
Last edited:
I have the following entry in the "/etc/network/interfaces" directory of VM 102. What do I need to add to get an IP address assigned from VLAN 200?
Code:
root@freepbx:~# cat /etc/network/interfaces
# Diese Datei beschreibt die auf Ihrem System verfügbaren Netzwerkschnittstellen
# und wie man sie aktiviert. Weitere Informationen finden Sie unter interfaces(5).

Quelle /etc/network/interfaces.d/*

# Die Loopback-Netzwerkschnittstelle
auto lo
iface lo inet loopback

# Die primäre Netzwerkschnittstelle
Hotplug zulassen ens18
iface ens18 inet dhcp
These are the network settings on the Proxmox host:
Code:
root@psme02:~# cat /etc/network/interfaces
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!

auto lo
iface lo inet loopback

auto enp12s0
iface enp12s0 inet manual

auto enp13s0
iface enp13s0 inet manual

auto enp14s0
iface enp14s0 inet manual

auto enp15s0
iface enp15s0 inet manual

iface ens6f0 inet manual

iface ens6f1 inet manual

auto bond0
iface bond0 inet manual
    bond-slaves enp12s0 enp13s0 enp14s0 enp15s0
    bond-miimon 100
    bond-mode 802.3ad
    bond-xmit-hash-policy layer2
#psme02 bond

auto vmbr0
iface vmbr0 inet static
    address 192.168.20.22/24
    gateway 192.168.20.1
    bridge-ports bond0
    bridge-stp off
    bridge-fd 0
    bridge-vlan-aware yes
    bridge-vids 2-4094

auto vmbr0.200
iface vmbr0.200 inet static
    address 192.168.200.22/24

source /etc/network/interfaces.d/*
 
Last edited:
If your VM has it‘s NIC on vmbr0 and you added the appropiate tag (200) on the vNIC interface within the GUI everything else depends on your network setup (DHCP reachable for VLAN 200 etc.).
 
I was able to solve my problem.
I created a bridge on the Proxmox server that includes all VLANs:
see Appendix 1
In the data center under the Proxmox host in the VM, I had to create another network device with the VLAN tag 200:
see Appendix 2
After that, I was able to create in VM 102 another interface in the "/etc/network/interfaces" directory, which then received an IP address from VLAN 200 via DHCP:
Code:
root@freepbx:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens18
## iface ens18 inet dhcp
iface ens18 inet dhcp

allow-hotplug ens19
## iface ens19 inet dhcp
iface ens19 inet dhcp
 

Attachments

  • 2025_09_19_Proxmox-Host-Bridge.png
    2025_09_19_Proxmox-Host-Bridge.png
    134.9 KB · Views: 6
  • 2025_09_19_Proxmox-VM-VLAN.png
    2025_09_19_Proxmox-VM-VLAN.png
    124.2 KB · Views: 6
I still dont understand why you create vlan-bridges on your node and use the vmbr0 with tagged frames in your vm. But you do you, glad its working for you.

Please be so kind and change the thread to [SOLVED]. Thanks :-)
 
Last edited:
I still dont understand why you create vlan-bridges on your node and use the vmbr0 with tagged frames in your vm. But you do you, glad its working for you.
Then I don't understand what you mean? What do I need to configure on my node? Which network device do I need to create on the VM, and what look like should my interface file on the VM?
 
Use can add vlan to vm use multiple nics
and tag vlan id and setting static ip to vm with no default route.