Quantcast
Channel: Proxmox Support Forum
Viewing all articles
Browse latest Browse all 170561

Configuring automatic vmbrXvY bridges.

$
0
0
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/130...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:

iface vmbr0v4 inet manual
    bridge_ports eth0.4
    bridge_stp off
    bridge_fd 0
    post-up /usr/local/bin/post-up-vmbr0v4

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

Viewing all articles
Browse latest Browse all 170561

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>