I utilize centos7 images on the ubuntu host, and they all work fine. Any time an image is started up, it gets IPv4 automatically.
But: I had just CREATED a FRESH RHEL 7 image, through a small script by building everything onto a rootfs and creating a .tar.gz at the end. When this is imported, this container / snapshot does NOT get the IPv4 address on ‘lxc start or import’. It does seem to get the IPv6 on ‘lxc start or import’.
So, my solution was 'lxc exec $NAME – dhclient` , which then assigns a new IP address.
Is there a cleaner way to have the RHEL container created where it automatically gets the IPv4 renewed? (Metadata and just a miniscule templates directory files are attached)
PS: lxc network get lxdbr0 ipv4.dhcp was default, and I had manually set it to true.
Also:
lxc profile show default ==> outputs this::
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:
- /1.0/containers/sut-781
- /1.0/containers/sut-18340
This is what I see:
±------------------±--------±---------------------±----------------------------------------------±-----------±----------+
| sut-18340 | RUNNING | 10.38.207.241 (eth0) | fd42:f21a:8d11:f9df:216:3eff:fe4d:d209 (eth0) | PERSISTENT | 1 |
±------------------±--------±---------------------±----------------------------------------------±-----------±----------+
| sut-781 | RUNNING | | fd42:f21a:8d11:f9df:216:3eff:fe98:d301 (eth0) | PERSISTENT | 0 |
±------------------±--------±---------------------±----------------------------------------------±-----------±–
The metadata.yaml file is:
architecture: “x86_64”
creation_date: REPLACE_EPOCH_TIME
properties:
architecture: “x86_64”
description: “Red Hat Enterprise Linux release 7.8”
os: “redhat”
release: “7”
cat templates/hosts.tpl
127.0.1.1 {{ container.name }}
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
cat templates/ifcfg-eth0.lxd.tpl
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HOSTNAME={{ container.name }}
NM_CONTROLLED=no
TYPE=Ethernet
MTU=
DHCP_HOSTNAME={{ container.name }}
cat templates/network.lxd.tpl
NETWORKING=yes
HOSTNAME={{ container.name }}