madnuttah / unbound-docker

🛡️ This distroless Unbound Docker image is based on Alpine Linux with focus on security, privacy, performance and a small image size. And with Pi-hole in mind.
https://hub.docker.com/r/madnuttah/unbound
MIT License
245 stars 21 forks source link

Help setting up parameters in docker-compose.env #6

Closed mondsen closed 2 years ago

mondsen commented 2 years ago

First of all, thank you for providing this. I am currently using pi-hole + unbound + hyperlocal on my Raspberry Pi ZeroW. It works, but somehow struggles with WLAN connection. Thus I have to migrate to my wired Raspberry Pi4 and would like to use your docker setup.

My network: 192.168.178.1: router (uses domain fritz.box) 192.168.178.78: rp4 (here I would like to host your docker files --> new DNS) 192.168.178.200: rpzero (my current and soon old DNS)

I am struggling to understand the internal IP management in the docker file. I thought, IPs in docker are internal (docker provides an own network configuration). Therefore I don't understand why I have to provide individual IP adresses for pihole and unbound. I have never used MACVLAN and I am not experienced with docker network configurations. Any help would be appreciated.

Furthermore, what do I need to specify for section pihole domainname VIRTUAL_HOST CORS_HOST REV_SERVER_DOMAIN section unbound domainname volumes (can I just use everything after <>?)

section networks how do these settings correlate to the settings above?

madnuttah commented 2 years ago

Hello and thanks for reaching out. I'm currently on vacation so bear with me if my responses are taking longer as expected. ~I suggest to start with a bridged configuration instead of a MACVLAN network to avoid frustrations by using advanced configurations for starters.~ You would need to provide network details (MAC address and IP address) for the hosts only if you intend to use a MACVLAN config. If so you also need to specify an IP range where the IP addresses for both machines will be reserved and then configured for the hosts in their respective sections. This will be done in the MACVLAN network configuration at the end of the file underneath the ipam section. I hope this answers your question regarding section networks

Furthermore, what do I need to specify for section pihole

section unbound

Could you provide your failing docker-compose file without any private details, please?

I'll simplify and provide more example docker-compose files since I don't think it's a good idea to show advanced networking principles in an example. This is confusing for real. I like to have a MACVLAN configuration because I want to have the hosts behaving like separate machines on my network. This has also another drawback that the host which is running Pi-hole and Unbound cannot access the container's services as the MACVLAN network is isolated from the host which is no problem for me as I use another forwarder for the host running Pi-hole and Unbound to provide name resolution.

I thought it was a good idea to provide such an example as I was struggling to make it run when I started using Pi-hole with Unbound. Obviously it isn't. Sorry for that.

Thanks for using my image, please get back to me if you want me to view your docker-compose.yaml or something wasn't clear. Yup, I had a few beers already. 🍻

mondsen commented 2 years ago

Thanks for your reply. I changed the networks section to this now:

networks:
  dns-network:
    driver: bridge

But now I am searching the internet for a proper solution for pointing the pi-hole container dns to the unbound container. There is a possibility to used fixed IPs within the service configuration, but I would like to have a more "robust" solution. Do you know if it is possible to use the container_name in the dns part for the pi-hole configuration? My guess is no, because I have only seen examples using IPs. Any recommendation for this?

madnuttah commented 2 years ago

Let's try it like so :

Configure the following in the networks section:

networks:
  dns-network:
    driver: macvlan
    driver_opts:
      parent: <eth0> #Adapt this to your raspberrys network interface
    ipam:
      config:
        - subnet: 192.168.178.0/24    
          gateway: 192.168.178.1    
          ip_range: 192.168.178.253/30

Give Pi-hole the following IP address: 192.168.178.254

and Unbound the following IP address: 192.168.178.253

You need to make sure that the DHCP Server of your router doesn't assing the. 253 and. 254 IPs. May you can make a reservation of this small range.

madnuttah commented 2 years ago

@mondsen is this issue resolved or do you need further assistance?