3. inside the container, deactivate dhcp (dhcp4: false )in `/etc/netplan/10-lxc.yaml`, and install the systemd packages without the bug,
```bash
lxc-attach -n bionic
sed -i 's/true/false/' /etc/netplan/10-lxc.yaml
apt install systemd=237-3ubuntu10.38 libsystemd0=237-3ubuntu10.38 libnss-systemd=237-3ubuntu10.38 libpam-systemd=237-3ubuntu10.38
exit
```
4. create a bridge on the host with a static IP and deactivate dhcp, in `/etc/network/interfaces`,
```
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
## The primary network interface
#allow-hotplug ens18
#iface ens18 inet dhcp
## This is an autoconfigured IPv6 interface
#iface ens18 inet6 auto
5. on the host, modify the network configuration of the container to use the bridge with a static IP in `/var/lib/lxc/bionic/config`,
```
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template:
# Template script checksum (SHA-1): 273c51343604eb85f7e294c8da0a5eb769d648f3
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
Here is a full procedure to reproduce the issue.
Set-up
======
1. Install an amd64 Debian Buster (default network install),
2. install lxc and create a bionic amd64 container,
```bash
apt install lxc
lxc-create -t download -n bionic
lxc-start -n bionic
```
3. inside the container, deactivate dhcp (dhcp4: false )in `/etc/netplan/ 10-lxc. yaml`, and install the systemd packages without the bug, 10-lxc. yaml 237-3ubuntu10. 38 libsystemd0= 237-3ubuntu10. 38 libnss- systemd= 237-3ubuntu10. 38 libpam- systemd= 237-3ubuntu10. 38
```bash
lxc-attach -n bionic
sed -i 's/true/false/' /etc/netplan/
apt install systemd=
exit
```
4. create a bridge on the host with a static IP and deactivate dhcp, in `/etc/network/ interfaces` ,
```
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/ interfaces. d/*
# The loopback network interface
auto lo
iface lo inet loopback
## The primary network interface
#allow-hotplug ens18
#iface ens18 inet dhcp
## This is an autoconfigured IPv6 interface
#iface ens18 inet6 auto
iface ens18 inet manual
auto br0
iface br0 inet static
address 192.168.1.168
netmask 255.255.255.0
gateway 192.168.1.220
bridge_ports ens18
bridge_stp off
bridge_waitport 0
bridge_fd 0
```
5. on the host, modify the network configuration of the container to use the bridge with a static IP in `/var/lib/ lxc/bionic/ config` , lxc/templates/ lxc-download 5f7e294c8da0a5e b769d648f3 conf(5)
```
# Template used to create this container: /usr/share/
# Parameters passed to the template:
# Template script checksum (SHA-1): 273c51343604eb8
# For additional config options, please look at lxc.container.
# Uncomment the following line to support nesting containers: lxc/config/ nesting. conf
#lxc.include = /usr/share/
# (Be aware this has security implications)
# Distribution configuration lxc/config/ common. conf
lxc.include = /usr/share/
# For Ubuntu 14.04 security sys/kernel/security none bind,optional 0 0 create= dir,optional 0 0
lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none bind,optional 0 0
lxc.mount.entry = /sys/kernel/
lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none bind,optional 0 0
lxc.mount.entry = mqueue dev/mqueue mqueue rw,relatime,
lxc.arch = linux64
# Container specific configuration profile = generated allow_nesting = 1 lib/lxc/ bionic/ rootfs
lxc.apparmor.
lxc.apparmor.
lxc.rootfs.path = dir:/var/
lxc.uts.name = bionic
## Network configuration
#lxc.net.0.type = empty
# Network configuration 0.ipv4. gateway = 192.168.1.220 0.ipv4. address = 192.168.1.169/32
lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = br0
lxc.net.0.name = eth0
lxc.net.
lxc.net.
```
6. reboot the host.
```bash
reboot
```
Let’s do it
===========
1. Start the container and check the IP config, which should be ok,
```bash
lxc-start -n bionic
lxc-attach -n bionic
ip a
```
2. upgrade the system and check the IP config, the static is gone.
```bash
apt upgrade
ip a
exit
```
If systemd is downgraded again to 237-3ubuntu10.38, the IP is back at the next reboot of the container.