Adding a Second (Tagged) Interface to a VM

norsemangrey

Member
Feb 8, 2021
63
9
13
39
I have an Ubuntu VM for which I want two interfaces: one interface for untagged traffic (i.e. VLAN 1) and one for a specific VLAN. I am not quite sure about the correct way to configure this in Proxmox.

I have a VLAN aware bridge where a VLANs are trunked (vmbr4) and if I create a VM with a network card either untagged or tagged (e.g. with VLAN 200), that interface on the Ubuntu VM is assigned an IP address in the correct VLAN range.

However, if I add a second network card, that interface shows up (ens19 in the below snapshot), but the link is DOWN and is not assigned an IP from the DHCP.

1672253269761.png

Am I missing something or is this the wrong approach to assigning multiple network interfaces / vlans to a VM?
 
  • Like
Reactions: iprowell
What is the error when you try to up that ens19 inside the VM? I'd guess the problem is your guests network config. It's usually no problem to add multiple virtual NICs to a VM and use VLAN.

When using VLAN1 and tagging a virtual NIC with VLAN1, keep in mind that those packets will be tagged so your switch needs to allow tagged VLAN1. If you want to send untagged packets, you could add a virtual NIC without any VLAN tag. But then the VM would also be able to listen to packets of all VLANs, in case that is a security concern for you.

What does your PVEs network config (/etc/network/interfaces) and your guests network config look like?
 
Last edited:
  • Like
Reactions: iprowell
If i try to up the link the link status goes to UP (I do not see any error message), but it still does not get any IP.
Code:
sudo ip link set dev ens19 up

1672309276647.png

I have not done anything with the Guest OS network config in particular. It is an Ubuntu Server image on which I have installed UFW and Docker and that's about it.

PVE network config.
Code:
auto vmbr4
iface vmbr4 inet manual
        bridge-ports enp2s0f3
        bridge-stp off
        bridge-fd 0
        bridge-vlan-aware yes
        bridge-vids 2-4094
1672309568864.png

Guest network config.
1672309816033.png
 

Attachments

  • 1672309742318.png
    1672309742318.png
    48.2 KB · Views: 4
  • 1672309746640.png
    1672309746640.png
    48.2 KB · Views: 3
  • Like
Reactions: iprowell
I managed to solve it.

I had to go into the network configuration on the guest OS and add the new interface (ens19) for dynamic address assignment. I would have thought this would happened automatically when a new interface is added.

/etc/netplan/00-installer-config.yaml

Code:
network:
  ethernets:
    ens18:
      dhcp4: true
    ens19:
      dhcp4: true
  version: 2
 
  • Like
Reactions: iprowell
When using VLAN1 and tagging a virtual NIC with VLAN1, keep in mind that those packets will be tagged so your switch needs to allow tagged VLAN1. If you want to send untagged packets, you could add a virtual NIC without any VLAN tag. But then the VM would also be able to listen to packets of all VLANs, in case that is a security concern for you.
This is a good point. I would like for the VM to only listed for packets on the selected VLAN. I am using untagged VLAN / VLAN 1 as a management VLAN which an application on the VM should have access to. Not sure what you mean exactly when you say that the switch needs to allow tagged VLAN 1. My router is also running as a VM on Proxmox so there is not a physical switch between the router and the VM. All VLANS are trunked trough vmbr4, but when adding VLAN 1 as an interface on the VM is there a difference between setting the VLAN Tag to 1 and not setting it at all?
 
  • Like
Reactions: iprowell
All VLANS are trunked trough vmbr4, but when adding VLAN 1 as an interface on the VM is there a difference between setting the VLAN Tag to 1 and not setting it at all?
Yes. When setting your virtio NICs "VLAN Tag" to 1, your VM will send untagged packet, they will be tagged with VLANID 1 and your router VM then has to allow incoming packets tagged with VLANID 1.
When not setting any "VLAN Tag" for the virtio NIC and also not tagging packets with a VLAn inside that VM, PVE won't tag those packets. Those packets will be untagged so your router VM needs to be configured to properly handle untagged packets. For example allowing incoming untagged packets and then tag them internally with VLAN 1 as PVID.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!