ifreload with new bridge

Fredware

Active Member
Jun 7, 2019
10
0
41
55
Hello,
I tried to configure proxmox with ansible.

In my workflow, I put on proxmox a interfaces.new

Code:
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!

auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet static
       address  {{ pve_ip }}
       netmask  255.255.255.0
       gateway  {{ ansible_default_ipv4.gateway }}
       bridge-ports enp3s0
       bridge-stp off
       bridge-fd 0

auto vmbr1
iface vmbr1 inet static
       address  10.0.0.1
       netmask  24
       bridge-ports none
       bridge-stp off
       bridge-fd 0

       post-up echo 1 > /proc/sys/net/ipv4/ip_forward
       post-up   iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
       post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE

And after a simple:
Code:
       - name : Proxmox Interfaces
          shell: ifreload -a

But not working.

When I try manually ifreload -a:
Code:
root@pve:~# ifreload -a
warning: cmd '/bin/ip addr del 192.168.10.255/24 dev vmbr0' failed: returned 2 (RTNETLINK answers: Cannot assign requested address
)

This my pending configuration, waiting I click on apply configuration, but no, I want I by ansible :P
Code:
--- /etc/network/interfaces    2020-04-06 09:16:53.099999477 +0200
+++ /etc/network/interfaces.new 2020-04-06 15:06:45.757428183 +0200
@@ -1,3 +1,14 @@
+# network interface settings; autogenerated
+# Please do NOT modify this file directly, unless you know what
+# you're doing.
+#
+# If you want to manage parts of the network configuration manually,
+# please utilize the 'source' or 'source-directory' directives to do
+# so.
+# PVE will preserve these directives, but will NOT read its network
+# configuration from sourced files, so do not attempt to move any of
+# the PVE managed interfaces into external files!
+
auto lo
iface lo inet loopback

@@ -8,6 +19,18 @@
address 192.168.10.172
netmask 255.255.255.0
gateway 192.168.10.1
- bridge_ports enp3s0
- bridge_stp off
- bridge_fd 0
+ bridge-ports enp3s0
+ bridge-stp off
+ bridge-fd 0
+
+auto vmbr1
+iface vmbr1 inet static
+ address 10.0.0.1
+ netmask 24
+ bridge-ports none
+ bridge-stp off
+ bridge-fd 0
+
+ post-up echo 1 > /proc/sys/net/ipv4/ip_forward
+ post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
+ post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE

Any ideas?
Thanks
 
"ifreload -a" only apply configuration from /etc/network/interfaces, not pending configuration from "/etc/network/interfaces.new".

you can try to do

"pvesh set /nodes/<mynode>/network"


or "mv /etc/network/interfaces.new /etc/network/interfaces; ifreload -a"



(BTW, I'm not sure what if your ifreload error, did you have added 192.168.10.255/24 manually ? seem strange as it's a broadcast address)
 
Hello,
I tried and it's work like you said:
Code:
mv /etc/network/interfaces.new /etc/network/interfaces; ifreload -a
But I'm not sure with all install/remove of ifupdown, if proxmox out-of-box work like this too.

Thanks!
 
But I'm not sure with all install/remove of ifupdown, if proxmox out-of-box work like this too.
Thanks!
this is the way proxmox is working.

when you reboot, the /etc/network/interfaces.new is move to /etc/network/interfaces,

and when you reload, the .new is also moved then ifreload -a is called.