Setting Up isc-dhcp-server and Bind9 in a LXC container

Hi,
I am trying to setup isc-dhcp-server and Bind9 in the same and different LXC containers. However, I am having difficulties to set the right bridge and ip configurations both on the host and container side to a get valid link between them.
I have following computers to test this project.
Host PC: Ubuntu 18.04,
interfaces: wlan0(IP:10.0.3.96/24, connected to AP to access to the Internet) and
eth0(will link/serve LXD/LXC ubuntu16.04 containers to run services for LAN)

Client PC : Ubuntu 16.04,
interfaces: wlan0 (IP:10.0.3.99/24, connected to AP to access to the internet) and
eth0(will connect to LAN/LXC containers to get dhcp and bind9 services)

AP Router: The Router has the IP range of 10.0.3.96-10.0.3.99/24, GW:10.0.3.95. I would like to use my LXC container as a Redundancy dhcp server to serve IP addresses in the LAN with the IP range of 10.0.3.91-10.0.3.94.

Thanks in advance!

Hi!
If I understand correctly, you want to have your containers get IPs from the LAN. You want them to appear with a LAN IP and be accessible as yet another LAN PC.

You can do that either with a bridge or with macvlan. However, you need to connect the computer with an Ethernet cable to the router.
Because WiFi expects only one MAC address from a wireless connection. With Ethernet, most routers allow you to connect some switch or hub in a port, so they accept more MACs.

Hi @simos Thanks for you quick response.

I drew a diagram which I thought might help to express my project better.

Hi @simos , Any idea of how should configure the bridge and IPs both on the host and container sides?

Thanks in advance !

You want containers from these two computers (Host, Ubuntu16.04) to communicate with each other.
Because of the WiFi, you cannot use a (non-private) bridge or macvlan to expose the containers onto the local network. If you can connect these two computers with Ethernet cable, then you can do so.

If you still insist on trying out with WiFi, then you might be able to do this with Clustering. See https://lxd.readthedocs.io/en/latest/clustering/ for more.

I would like to expose the containers from the Ethernet port (eth0, on the host). I don’t want to link them through the Wifi. I want to connect the containers and the Client computers with Ethernet cable.

So both the Host and Client would have WiFi connections to the Internet.
And at the same time you will connect them with each other with an Ethernet cable (directly, PC Ethernet port to PC Ethernet port, without a router).

You need to have different subnets between the Ethernet and WiFi links, because the Host and Client will not be able to route traffic. The scenario will make sense when one actually tries to implement it so it is not clear to me how to do all these. Perhaps someone else has some better hints.

Let’s say I will use a different subnet and what Network configuration should I set (on host and container) if I want to connect them with each other with an Ethernet cable (directly, PC Ethernet port to PC Ethernet port, without a router) ?

Without a router/switch it would be a bit complicated to explain.
If you can have a router and connect the two PCs to the router with Ethernet cable, then you can put all LXD containers on a bridge (as in https://blog.simos.info/how-to-make-your-lxd-containers-get-ip-addresses-from-your-lan-using-a-bridge/) and everything will be able to connect with everything else.

I have reinstalled the LXD and enabled to expose containers over the network at Lxd init configuration, now all my containers are reachable on the LAN/network.

Great news! Can you give a summary of what you chose to do with the networking?

$ sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir, lvm, zfs) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing block device? (yes/no) [default=no]: yes
Path to the existing block device: /dev/sda7
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like thttp://pjp.dgplug.org/ndjbdnso create a new network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: br0
Is this interface connected to your MAAS server? (yes/no) [default=yes]: no
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes

We have configured br0 as a bridge in Ubuntu.

/dev/sda7 is an unmounted partition

With lxc launch we are able to create a primary secondary dhcp using isc-dhcp-server.
For dns we use pjp.dgplug.org/ndjbdns
This setup works perfectly for us within containers.