Networking problems with custom container templates

spiritlhl

Member
Apr 4, 2023
11
2
8
From https://www.reddit.com/r/homelab/comments/5xvfbf/how_to_proxmox_modify_a_ct_container_template/

This method is really fine for the first time, but it will be problematic in the long run because if I execute the reboot command inside the container, it will cause the container's network configuration to go to the container's default configuration before packaging instead of going to the PVE configuration, which will result in an intranet IP change.

I'm executing.

```
pct set CTID --delete net0
```

to delete the corresponding network configuration, but this doesn't seem to work.
For example, the container I'm using is a debian11 system, and after deletion there is still legacy configuration in /etc/network/interfaces within the container.
1708162168243.png


At this point I'm not sure how to fix it, it seems that I'm using the pct command to create and enter containers to modify templates causes certain one-time settings to no longer be enforced. My modified zst container file is no longer containerized to configure the network again.

Is there any command/method to force the network configuration file inside the container (in debian containers it's the /etc/network/interfaces file) to be synchronized with the configuration outside the container (the container network configuration as seen in pve's web)?
 
One idea for a solution, I'll have to recreate my container template, it seems that because I used eth0 as the net0 name in the first configuration, and the second time I imported the modified container file still using eth0 as the net0 name, the network configuration inside the container won't be refreshed automatically, I need to change the name of the net0 in the first configuration not to use eth0 in order to avoid the network not to be reloaded.
 
Troubleshooting reveals

pct exec $CTID -- touch /etc/network/.pve-ignore.interfaces

is not required, and after reboot, it will cause IPV4 changes on the intranet because of the residual files.