Bulk adding SDN VLANs/VNets

Aug 24, 2020
7
0
21
Philadelphia, PA
I have a currently 4-node proxmox cluster (more coming soon), and I have on each node a bridge connected to a bond for two adapters dedicated for my VM's to talk to each other. I need to create about 100 vlans, and with the migrations from my old vmware stacks, I may add up to 300 vlans.

My linux bond is bond0, which is connected to vmbrSRVC. It's identical for each server. I prepped one server then copied the interfaces file to every other server and only incremented its ips.

Screenshot 2025-04-25 at 22.54.13.png

I go in and create my SDN Zone, that I just called VMNet (for now), then I made my VNets connected to VMNet.
Screenshot 2025-04-25 at 22.57.10.png

Afterwards I can go in and obviously apply them. However it may be a bit tedious to do that 1 by 1.

Is there a way to bulk add vlans, maybe from commandline? Modifying a config file?

I do not need stacked vlans and I'm not using the DHCP features. That will come from virtual firewalls.
 
I did find /etc/pve/sdn and my vnets.cfg has this so far:
Code:
vnet: vlan910
        zone VMNet
        alias vlan910
        tag 910
        vlanaware 1

vnet: vlan911
        zone VMNet
        alias vlan911
        tag 911
        vlanaware 1

vnet: vlan912
        zone VMNet
        alias vlan912
        tag 912
        vlanaware 1

vnet: vlan913
        zone VMNet
        alias vlan913
        tag 913
        vlanaware 1

vnet: vlan914
        zone VMNet
        alias vlan914
        tag 914
        vlanaware 1

#1 Can I just have AI or something expand that to all my vlans. How do I then update it across all hosts, unless I have to copy/paste it?

#2 Do these *need* to be vlan aware? If I am tagging them then I don't think so. I want to specifically avoid any ability to stack vlans or have a nefarious actor to jump vlans.
 
So I did this:
Python:
#!/usr/bin/env python3

zone_name = "VMNet"

with open("vnets.cfg", "w") as f:
     for vlan_id in range(701, 999):
         vnet_name = f"vlan{vlan_id}"
         f.write(f"vnet: {vnet_name}\n")
         f.write(f"\tzone {zone_name}\n")
         f.write(f"\talias {vnet_name}\n")
         f.write(f"\ttag {vlan_id}\n")
         f.write(f"\tvlanaware 0\n")
         f.write("\n")

And it made the config. But my oh my do the servers not want to ifreload that. They are stuck networking reloading for minutes now.

EDIT: OK, That was bad.... I reverted it and still had to reboot.
 
Last edited: