Configuring automatic vmbrXvY bridges.

jjoos

New Member
Jun 4, 2013
5
0
1
Groningen, Netherlands
I was changing some network config on our hosts and ran in to ifupdown-ing a bridge and than all the tap devices are disabled ( http://forum.proxmox.com/threads/13...king-retart-Now-Guests-have-no-network-access ).

So I build a quick and dirty fix for it:

Code:
#!/usr/bin/env bash

hostname=`hostname`
script_name=`basename $0`
bridge_number=${script_name: -1:1}


result=`grep vmbr$bridge_number /etc/pve/nodes/$hostname/qemu-server/*.conf \
  | sed -E "s/^.*server\/([0-9]+).conf\:net([0-9]+)\:\s.*bridge\=(vmbr[0-9]+)(,tag=([0-9]+))?$/brctl addif \3v\5 tap\1i\2/" \
  | sed -E "s/(^.*vmbr[0-9])v(\s.*$)/\1\2/"`


while read -r line
do
  # get status for vm
  vm_id=`echo $line | sed -E "s/^brctl addif vmbr[0-9]+(v[0-9]+)? tap([0-9]+)i.*$/\2/"`
  echo "Checking if $vm_id is running."
  status=`qm status $vm_id`


  # check if vm is running
  if [[ $status == "status: running" ]]; then
    # remove trailing v when there is no tag
    if [[ ${line: -1:1} == "v" ]]; then
      line=${line: 0:-1}
    fi
    echo "$line"
    $line
  fi
done <<< "$result"


# always exit with succes otherwise the device will be completely down
exit 0

And added a post-up hook to my /etc/network/interfaces:
Code:
auto loiface lo inet loopback


auto eth0
iface eth0 inet manual


auto vmbr0
iface vmbr0 inet manual
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    post-up /usr/local/bin/post-up-vmbr0


auto eth1
iface eth1 inet static
    address 172.18.100.1
    netmask 255.255.255.0


auto vmbr1
iface vmbr1 inet static
    address 172.18.100.1
    netmask 255.255.255.0
    gateway 172.18.100.11
    bridge_ports eth1
    bridge_stp off
    bridge_fd 0
    post-up /usr/local/bin/post-up-vmbr1

But now I'm also connecting tap devices to vmbr0v1 post-up to vmbr0, but vmbr0v1 never went down in the first place.

So is it possible to add the vmbrXvY bridges explicitly to my /etc/network/interfaces, that way I can give them their own post-up directive

Should it look like this?:
Code:
[COLOR=#333333]iface vmbr0v4 inet manual[/COLOR]
[COLOR=#333333]    bridge_ports eth0.4[/COLOR]
[COLOR=#333333]    bridge_stp off[/COLOR]
[COLOR=#333333]    bridge_fd 0
[/COLOR]    post-up /usr/local/bin/post-up-vmbr0v4

(offcourse I have to edit the script to support these new type of bridges)
 

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!