Hi all,
I have a two node cluster PVE 7.3-4 on different data centers with different public networks.
LXC container running on node1 and replicated to node2.
I need to change container's network settings (MAC addres, ip-addres and gw) when it migrated on node2 and change it back when it migrated back on node1.
So I created hook-scripts at snippets on both nodes that change container's network settings on pre-start phase.
Script:
User "www-data" can sudo /usr/sbin/pct set *
Script works well when I run it by hand from user "www-data" but throw an error when it called by proxmox.
Output:
Have somebody any idea how to automate changing network settings on container start?
I have a two node cluster PVE 7.3-4 on different data centers with different public networks.
LXC container running on node1 and replicated to node2.
I need to change container's network settings (MAC addres, ip-addres and gw) when it migrated on node2 and change it back when it migrated back on node1.
So I created hook-scripts at snippets on both nodes that change container's network settings on pre-start phase.
Script:
Bash:
#!/bin/bash
ID=$1
PHASE=$2
echo "CT HOOK: $ID, PHASE: $PHASE"
case $PHASE in
pre-start)
if [[ "x$ID" == "x105" ]]; then
echo pct set $ID -net0 name=eth0,bridge=vmbr0,firewall=0,gw=1.2.3.1,hwaddr=00:00:00:01:02:03,ip=1.2.3.115/24
sudo /usr/sbin/pct set $ID -net0 name=eth0,bridge=vmbr0,firewall=0,gw=1.2.3.1,hwaddr=00:00:00:01:02:03,ip=1.2.3.115/24
fi
;;
*)
exit 0
;;
esac
User "www-data" can sudo /usr/sbin/pct set *
Script works well when I run it by hand from user "www-data" but throw an error when it called by proxmox.
Output:
Code:
GUEST HOOK: 105, PHASE: pre-start
pct set 105 -net0 name=eth0,bridge=vmbr1,firewall=0,gw=1.2.3.1,hwaddr=00:00:00:01:02:03,ip=1.2.3.115/24
trying to acquire lock...
can't lock file '/run/lock/lxc/pve-config-105.lock' - got timeout
TASK ERROR: hookscript error for 105 on pre-start: command '/var/lib/vz/snippets/pct105-net0 105 pre-start' failed: exit code 4
Have somebody any idea how to automate changing network settings on container start?
Last edited: