Assigning Static LAN IP address to LXD Container


I am attempting to utilize a LXD container to install a PiHole instance. The Host computer is running Ubuntu Server 18.10 and the container will run Ubuntu 18.04. I need to assign the container a static IP because the PiHole will operate as my DNS server. Additionally, it will need access to ports 53, 54 (dnscrypt) and 80 (lighttpd). My LAN IP range is Honestly I don’t think I know enough to ask the right questions so could anyone ELI5 to me? How do I assign - say - to this container? How would I think forward the appropriate ports.

Thank you!


PiHole is this, You install it as an appliance on your local network and you configure your devices to connect to it. The documentation is generally good, but requires digging to figure out the networking requirements.

Port 80 is the Web management dashboard, therefore it should be accessible by your LAN only.
Ports 53/54 should be accessible by your LAN as well.
But if you want all these (80, 53, 54) accessible only by your host, then it gets simpler but you have to say so.

It does not appear that the PiHole needs to be accessible from the Internet, therefore there is no need for port forwarding and things like that. The PiHole will be initiating any connections to the Internet.

I assume that you want the PiHole container to be accessible by the LAN (not only the host which is simpler).
In that case, get the LXD container to get the IP address from your LAN by following a tutorial like
You can make this a static IP through your LAN router. Your LAN router should have a management webserver (at or to set the IP address as static.
In fact, that’s it. If PiHole still complains, you can set manually that IP address you got from the router’s DHCP server into the container, and your container will be happy use it as a static IP address.

The installation of pihole even asks for an fixed IP address and puts that as an extra IP on the interface. So would have 2 IP’s afterwards: 1 fixed and 1 by dhcp. It didn’t complain further with my container install.

Thank you Simos, I used your macvlan tutorial to get the static ip. Thank you for your awesome work.