How do I reserve a static IPv4 address (ie. DHCP reservation) over a macvlan interface?
I am running bare LXC (ie. no Incus or LXD) on a Debian host. The container is running unprivileged on a Debian image, and within it runs an instance of Pi-hole. From /var/lib/lxc/pi-hole/config
:
# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = linux64
# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.idmap = u 0 165536 65536
lxc.idmap = g 0 165536 65536
lxc.start.auto = 1
lxc.rootfs.path = dir:/var/lib/lxc/pi-hole/rootfs
lxc.uts.name = pi-hole
# Network configuration
lxc.net.0.type = macvlan
lxc.net.0.macvlan.mode = bridge
lxc.net.0.link = enp3s0
lxc.net.0.flags = up
lxc.net.0.name = eth0
lxc.net.0.hwaddr = c2:25:af:e6:6f:8e
lxc.net.0.ipv4.address = 192.168.1.2/24
lxc.net.0.ipv4.gateway = 192.168.1.1
lxc.net.0.ipv6.address = 2600:4040:9086:4f00:c025:afff:fee6:6f8e
lxc.net.0.ipv6.gateway = 2600:4040:9086:4f00::1
At the moment, I have a static IPv4 address reserved in my router. I would like to disable the DHCP server in my router and use a DHCP server from within my container. Unfortunately, when I disable the DHCP server in my router (and enable it in my Pi-hole container), my container loses its IPv4 address. The container’s DHCP server cannot function, and all the devices in my LAN subsequently lose their IPv4 addresses.
In my Debian host, I can just edit the /etc/network/interfaces
file to assign a static IP. Unfortunately, the LXC container has no such configs.
Is there anyway to reserve an IPv4 address for my container from the DHCP client side?