[SOLVED] how to give vm's dhcp leases from my router?

smenzer

New Member
Mar 29, 2023
5
0
1
Madison, NJ
I've searched everywhere but haven't been able to find the answer to this, so hoping someone here can help.

Goal: let my router provide static IP leases to my VMs (which may be on different VLANs).

My Setup:
  • WAN <--> Opnsense router <--> tplink managed switch <--> ibm thinkcentre running Proxmox <--> VMs (everything here is hardwired with ethernet)
  • I have several VLANs:
    • 1 = management (192.168.85.1/24) -- only has network hardware on it (switches/APs)
    • 10 = main (192.168.10.1/24) -- laptops, phones, proxmox
    • 20 = iot (192.168.20.1/24) -- for iot devices
    • and a few others that aren't important here
  • I've configured a linux bridge in proxmox to use dhcp and i successfully get the static ip i assigned -- 192.168.10.5:
  • here is the /etc/network/interfaces file:
Code:
auto lo
iface lo inet loopback

iface eno1 inet manual

auto vmbr0
iface vmbr0 inet dhcp
        bridge-ports eno1
        bridge-stp off
        bridge-fd 0
        bridge-vlan-aware yes
        bridge-vids 2-4094


I've created a virtual machine for home assistant (using the script from https://tteck.github.io/Proxmox/). In the hardware > networking configuration, I've set the VLAN to 10 (main) and I've copied the MAC address to my opnsense router and set a static IP lease of 192.168.10.15
1680656798559.png

When I boot up the VM, though, I'm not getting the right IP address:
1680657061636.png

I can't for the life of me figure out what I'm doing wrong so that proxmox passes through the IP from the router to the VM. Any guidance is greatly appreciated!! Let me know if you need any more details from me.
 
Hi,
does your Container communicate with the correct DHCP server? Are you able to ping it from inside the container. Also, check eventual logs of the dhcp client and server.
I've set the VLAN to 10 (main)
Try without setting the VLAN tag also from within the container, you are already tagging the packets via PVE.
 
  • Like
Reactions: smenzer
Try without setting the VLAN tag also from within the container, you are already tagging the packets via PVE.
I removed the VLAN tag and restarted and it seems to have picked up the right address now! I'll have to make sure it's all connected properly, but at first glance this seems to have worked!

If I want to have a container on a DIFFERENT VLAN from PVE (i.e. put a VM on the iot VLAN), would this be possible? Or do I need to set proxmox to be untagged and then individually tag the VMs inside of it?

[Edit] If the best approach is to keep proxmox untagged and tag each individual VM, does it make sense to then put proxmox itself on my management vlan and set a static ip (like i do with my network hardware)? i know there's no right/wrong answer here, but interested to hear opinions.
 
Last edited:
I ended up setting my "main" vlan as the untagged network and my other vlans as tagged networks on the port on my switch that connects to proxmox. then, for any vm that i want using the main vlan, i don't set a vlan on the vm's network adapter. if i want the vm to use one of my other vlans, i set it to the right one and it will get an ip on that subnet from the router.
 
@Chris I'm hoping you can help me out again here. I ended up just setting a static IP in the PVE because I had some complications with the DHCP leases and this was just simpler. My PVE interfaces file now looks like this:

Code:
auto lo
iface lo inet loopback

iface eno1 inet manual

auto vmbr0
iface vmbr0 inet static
        address 192.168.10.5/24
        gateway 192.168.10.1
        bridge-ports eno1
        bridge-stp off
        bridge-fd 0
        bridge-vlan-aware yes
        bridge-vids 2-4094

On my switch, I've set the port profile to leave my `main` vlan untagged and the other vlans tagged:
1681662240428.png

I've created a new VM LXC Container (the nginx one from https://tteck.github.io/Proxmox/) and I'm trying to get it to be on my `dmz` vlan. On the VM's container's network, if I leave it as just DHCP, it gets an IP from my `main` vlan (which makes sense).
Code:
root@nginx:~# ip a show eth0
2: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 0e:b1:a5:82:df:f9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.10.128/24 brd 192.168.10.255 scope global dynamic eth0
       valid_lft 6068sec preferred_lft 6068sec
    inet6 fe80::cb1:a5ff:fe82:dff9/64 scope link tentative
       valid_lft forever preferred_lft forever


But then if I set the VLAN Tag to 50 (my `dmz` vlan) in the network settings on the VM container, when I restart it doesn't get an IP:
1681662421000.png

Code:
root@nginx:~# ip a show eth0
2: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 0e:b1:a5:82:df:f9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::cb1:a5ff:fe82:dff9/64 scope link
       valid_lft forever preferred_lft forever

I'm really stuck...any advice or guidance you can offer is greatly appreciated!

[Edit to specify that I'm trying to get the dmz VLAN on a LXC container, not a VM]
 
Last edited:

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!