VLAN re-numbering : is it possible to script changes in VM .conf files?

christophe

Renowned Member
Mar 31, 2011
191
5
83
Hi all,

Today a VLAN was re-numbered. Say from 200 to 300. By the networking guys.

In our (three) proxmox clusters, we have more than 150 VM.
Some of them are connected to VLAN 200.

We need to move all of them to VLAN 300.

We tried via web guy on a few one : it works, live, no need to restart / reload anything.
The only thing done via gui in the conf file of each VM is :
- replace "tag=200" by "tag=300" for tagged NIC,
- replace "bridge=vmbr200" by "bridge=vmbr300" for NIC connected to a tagged vmbr.

But it takes soooo much time...

In order to do things quickly, I scripted this with :

cd /etc/pve/nodes
find . -name "*.conf" -type f -print0 |xargs -0 sed -i 's/tag=200/tag=300/g'
find . -name "*.conf" -type f -print0 |xargs -0 sed -i 's/bridge=vmbr200/bridge=vmbr300/g'

This is working correctly, files are exactly the same this way than via giu, BUT, new config is NOT taken into account!

Is there an easy way to reload and activate new VMs conf, without restarting networking stack?

Thanks,

Christophe.
 
If you use the `qm set` command instead of editing the .conf files directly, then the change should be applied immediately, provided the required hotplug option is set (which is on by default for networking).
Note that you need to specify the entire line, so first read the line you want to change, then perform the replacement, then apply it with `qm set $VMID -netx the_modified_data`.
 
Ah, yes!

But MODEL parameter is mandatory, and MAC address is needed if you want to keep it unchanged. I can't find a way to only give new tag or new bridge :
400 Parameter verification failed

Nevertheless, it is a good starting point.

Thanks,

Christophe.
 
But MODEL parameter is mandatory, and MAC address is needed if you want to keep it unchanged. I can't find a way to only give new tag or new bridge :

Again, you need to specify the entire line, so first read the line you want to change, then perform the replacement, then apply it.
 

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!