What is the pct command to toggle link_down while the container is live ?

shodan

Active Member
Sep 1, 2022
183
56
33
I create the container with link_down=1, so it doesn't obtain a dhcp address before I've re-arranged things inside the container.

But how do I turn link_down to 0 when the time is right ?
 
According to chatgpt, you have to redefine the entire network interface like

pct set 1002 -net0 name=eth0,bridge=vmbr0,ip=dhcp,link_down=0

Is that the best way to go about it, or is it possible to only toggle "link_down"'s value ?
 
So I made this simple shellscript

It takes the variable that I have used to create the container and re-uses it with link_down flipped to 0

Code:
replace_link_down() { _CT_net_config=${_CT_net_config//link_down=1/link_down=0}; echo "Updated _CT_net_config: $_CT_net_config"; pct set "$CT_ID" $_CT_net_config; }


This works, however the changes don't take effect immediately it seems.

I presume that rebooting the container will do.

Though it is a little annoying that a server would need to reboot just to "plug in the virtual network cable in" !