Adding Bridge without rebooting

Discussion in 'Proxmox VE: Networking and Firewall' started by Ben McGuire, Sep 25, 2016.

  1. Ben McGuire

    Ben McGuire Member
    Proxmox VE Subscriber

    Joined:
    Sep 14, 2016
    Messages:
    30
    Likes Received:
    0
    We hope there is a solution to being able to modify the network without rebooting the entire server.

    We have read that you can directly modify the /etc/network/interfaces file and you dont have to reboot but this has not worked for us.

    We need to two things. One to be able to add a bridge without restarting and two to be able to add nat forwarding rules to a bridge without rebooting.

    I have changed the file above but Proxmox is still telling me to reboot when viewing the network tab in proxmox.

    --- /etc/network/interfaces 2016-09-22 21:31:26.425698412 +0200
    +++ /etc/network/interfaces.new 2016-09-25 14:27:42.772806681 +0200
    @@ -30,7 +30,6 @@
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22222 -j DNAT --to 192.168.0.10:22
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22222 -j DNAT --to 192.168.0.10:22


    Can any one provide their solution to activate network changes without rebooting the server.
     
  2. duelle

    duelle New Member

    Joined:
    Sep 25, 2016
    Messages:
    5
    Likes Received:
    0
    1. Add bridge: I am not sure whether adding a bridge is possible without rebooting. One thing you could try is to restart the debian networking service, but I am not sure whether this works or if this has any side-effects on proxmox. To do so you could run service networking restart
      Perhaps you can find more details on what this command can change and what not in the documentation of the networking service (possibly).
    2. Add PREROUTING rule: If I got you correctly, you just want to add the rule iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22222 -j DNAT --to 192.168.0.10:22 to the current iptables rules? If so, you could just execute this command as root. Your changes to the file itself would then be applied on the next reboot and you would not have to execute this again manually.
    Especially for number 1 I am not sure whether this is doable and what effects the restart of the networking service of debian might have. So you do this on your own risk of course.
     
  3. wolfgang

    wolfgang Proxmox Staff Member
    Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    4,257
    Likes Received:
    269
    Hi,

    Yes it is possible. The reboot is only a protection, so you have to think twice before you look out .

    You can direct edit the /etc/network/interfaces.
    The /etc/network/interfaces.new will copied over /etc/network/interfaces when you reboot.
    This you can do this also manually.

    After changing this file you have to apply this settings.
    You can use for this ifdown <net> and ifup <net>.
    But if you work on ssh be aware you disconnect the network.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Ben McGuire

    Ben McGuire Member
    Proxmox VE Subscriber

    Joined:
    Sep 14, 2016
    Messages:
    30
    Likes Received:
    0
    Hello

    We did do exactly what you state above a few weeks ago except we did not use the ifdown and ifup so hopefully this will be the problem... I shall give it go go today and report back.

    Thank you
     
  5. Ben McGuire

    Ben McGuire Member
    Proxmox VE Subscriber

    Joined:
    Sep 14, 2016
    Messages:
    30
    Likes Received:
    0
    We ran ifdown && ifup and on both eth0 and vmbr0 and eth0 said the interface is not configured and same with vmbr0. After these commands all VMs lost connection and had to be rebooted.
    Now even after running the commands we still see the network configurations in the network tab saying we need to reboot so the command did not work.. Do we need to run the commands on eth0 or the vmbr0? The nat rues have been added to vmbr1 which is set a private IP as vmbr0 has our public IP assigned. I guess I will have to give customers notice and reboot the whole server as the command did not work.
     
  6. wolfgang

    wolfgang Proxmox Staff Member
    Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    4,257
    Likes Received:
    269
    The best way is to force the ifdown on all net devices (vmbr1->eth0)
    and the next thing is no VM should use the bridge.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. weerok

    weerok New Member

    Joined:
    Jun 2, 2016
    Messages:
    10
    Likes Received:
    0
    Hello,

    If vmbr have attached taps, after debian network restart, taps lose link to their vmbr's

    # brctl show
    bridge name bridge id STP enabled interfaces
    vmbr3320 8000.f40343440ad8 no bond1.3320
    tap12765i1


    #/etc/init.d/networking stop && /etc/init.d/networking start

    # brctl show
    bridge name bridge id STP enabled interfaces
    vmbr3320 8000.f40343440ad8 no bond1.3320

    So I made a workaround script:
    - Network restart take about 36 seconds (on my setup), but changes are applied without reboot,
    - Don't judge my scripting skills :)
    - Script export vmbr's taps, restart network, and reattach them

    #!/bin/bash


    echo ==== Proxmox Network-tap-ssh RESTART
    brctl show | grep 'vmbr' | awk '{print $1}' | while read line
    do
    >$line
    brctl show $line | egrep -v 'bridge name|vmbr' | awk {'print $1'} >> $line
    done

    /etc/init.d/networking stop && /etc/init.d/networking start

    ls |grep vmbr | while read line
    do
    input="$line"
    while IFS=',' read -r f1 f2 f3 f4 f5 f6 f7 f8 f9 f10
    do
    ip link set dev $f1 $f2 $f3 $f4 $f5 $f6 $f7 $f8 $f9 master "$input"
    done < "$input"
    done
     
  8. smartynov

    smartynov New Member

    Joined:
    Feb 8, 2019
    Messages:
    1
    Likes Received:
    0
    I ran into the same problem and found a solution here, thank you. However, I think it is better to read taps configuration from VM .conf files rather than trying (which btw does not work for me because of a slightly different output format).

    Therefore I ended up with the following one-liner, which I apply after "service networking restart":
    Code:
    grep -FH bridge= /etc/pve/nodes/*/qemu-server/*.conf \
     | perl -nle 'print "tap$1i$2 master $3" if /\/(\d+).conf:net(\d+):.*?bridge=(vmbr\d+)/' \
     | xargs -l1 echo ip link set
    Please use at your own risk only and make a DRY RUN FIRST. If you see reasonable commands, remove the word "echo" from last part of the command and run again to invoke actual changes.
     
  9. Stoiko Ivanov

    Stoiko Ivanov Proxmox Staff Member
    Staff Member

    Joined:
    May 2, 2018
    Messages:
    679
    Likes Received:
    55
    You could also try installing ifupdown2, which has an ifreload command, which should keep all tap-devices attached to the bridge
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    elmacus likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice