# pi-hole https://www.wundertech.net/how-to-setup-pi-hole-on-a-synology-nas-two-methods/ #### 1a. Créer un réseau macvlan: ```bash $ sudo docker network create -d macvlan -o parent=ovs_eth0 --subnet=192.168.2.0/24 --gateway=192.168.2.1 --ip-range=192.168.2.68/32 ph_network # 192.168.2.68 = IP Pi-hole # si VMM est installé: -o parent=ovs_eth0 # sinon: -o parent=eth0 ``` Equivalant yaml: ```yaml services: pihole: ../.. networks: macvlan: ipv4_address: 192.168.2.68 restart: always networks: macvlan: name: ph_network driver: macvlan driver_opts: parent: ovs_eth0 ipam: config: - subnet: "192.168.2.0/24" ip_range: "192.168.2.254/24" gateway: "192.168.2.1" ``` #### 1b. Bridge #### 2. docker-compose.yml ```yaml version: "3" # Instructions: https://www.wundertech.net/how-to-setup-pi-hole-on-a-synology-nas-two-methods/ services: pihole: container_name: pihole image: pihole/pihole:latest ports: - "53:53/tcp" - "53:53/udp" - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server - "80:80/tcp" networks: - ph_network environment: TZ: 'Europe/Paris' WEBPASSWORD: 'xxxxx' # Volumes store your data between container upgrades volumes: - '/volume1/docker/pihole/pihole:/etc/pihole' - '/volume1/docker/pihole/dnsmasq.d:/etc/dnsmasq.d' cap_add: - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed restart: unless-stopped networks: ph_network: name: ph_network external: true ``` #### 3. Ouvrir et configurer pihole: ```http # ip fixée dans le réseau http://192.168.2.68/admin/login.php ``` #### 4a. Régler les DNS dans le routeur: - DNS 1: - DN2 2: 1.1.1.1 Tous les appareils utiliseront Pi-hole comme serveur DNS. #### 4b. Régler les DNS dans chaque appareil: - DNS 1: - DN2 2: 1.1.1.1 Si on utilise un macvlan, le DSM ne peut accèder à Pi-hole. Il faut utiliser des DNS externes: - DNS 1: 9.9.9.9 (Quad9) - DN2 2: 1.1.1.1 (Cloudflare) #### 5. Listes: https://www.libhunt.com/topic/pi-hole-blocklists #### 6. Aller dans le containe pihole: ```bash $ sudo docker exec -it pihole bash ``` ```bash $ pihole -v ``` #### 7. Loopback Dans Pi-hole, aller à Local DNS -> DNS Records -> Add a new domain/IP combination: Ajouter /volume1/docker/pihole/dnsmasq.d/01-pihole.conf ```bash addn-hosts=/etc/pihole/local.list addn-hosts=/etc/pihole/custom.list localise-queries no-resolv log-queries log-facility=/var/log/pihole/pihole.log log-async cache-size=10000 server=8.8.8.8 server=8.8.4.4 interface=eth0 ``` /volume1/docker/pihole/dnsmasq.d/06-rfc6761.conf ```bash server=/test/ server=/localhost/ server=/invalid/ server=/bind/ server=/onion/ ``` #### Liens https://marketsplash.com/tutorials/docker/pihole-docker/ https://drfrankenstein.co.uk/pi-hole-in-container-manager-on-a-synology-nas/ https://www.wundertech.net/how-to-setup-pi-hole-on-a-synology-nas-two-methods/ https://github.com/pi-hole/docker-pi-hole