Hi all,
I have an issue where I’m trying to assign an unique IP address to a Pi-Hole Docker container on Debian 12 installed inside a VirtualBox VM in order to be able to host both self-hosted services and a DNS server on the same machine. As it’s recommended online, I have decided to configure a macvlan network in order to assign an unique IP address to a container. I am using a host-only network adapter in VirtualBox, given that for now it’s a testing setup before I decide on a solution that’s best for me. The IP address 192.168.92.3 is inaccessible from outside the container, making the Pi-Hole useless.
Pinging to the container doesn’t work, as the outside connectivity fails as well. I’ve spent multiple days trying to troubleshoot an issue, only to be disappointed at the end given that it’s my first time using macvlan.
Here’s my Docker Compose configuration:
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
networks:
pihole-vlan:
ipv4_address: 192.168.92.3
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80/tcp"
- "443:443/tcp"
environment:
FTLCONF_dns_listeningMode: 'all' # Volumes store your data between container upgrades
ServerIP: 192.168.92.3
volumes:
- ${PATH_TO_DATA}/pihole/etc-pihole:/etc/pihole
- ${PATH_TO_DATA}/pihole/etc-dnsmasq.d:/etc/dnsmasq.d
restart: unless-stopped
networks:
pihole-vlan:
driver: macvlan
driver_opts:
parent: enp0s8
ipam:
config:
- subnet: 192.168.92.0/24
gateway: 192.168.92.1
Here’s the output of pinging from a server:
$ ping 192.168.92.3
PING 192.168.92.3 (192.168.92.3) 56(84) bytes of data.
From 192.168.92.2 icmp_seq=1 Destination Host Unreachable
From 192.168.92.2 icmp_seq=2 Destination Host Unreachable
From 192.168.92.2 icmp_seq=3 Destination Host Unreachable
From 192.168.92.2 icmp_seq=4 Destination Host Unreachable
From 192.168.92.2 icmp_seq=5 Destination Host Unreachable
From 192.168.92.2 icmp_seq=6 Destination Host Unreachable
^C
--- 192.168.92.3 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 6151ms
Here’s how it looks on my PC:
C:\Users\[REDACTED]>ping 192.168.92.3
Pinging 192.168.92.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.92.3:
Packets: Sent = 3, Received = 0, Lost = 3 (100% loss),
Control-C
^C
Not only that, attempts to ping the host fail:
$ sudo docker exec -it pihole sh
/ # ping 192.168.92.2
PING 192.168.92.2 (192.168.92.2): 56 data bytes
^C
--- 192.168.92.2 ping statistics ---
6 packets transmitted, 0 packets received, 100% packet loss
Here is the IP route of a container:
/ # ip route
default via 192.168.92.1 dev eth0
192.168.92.0/24 dev eth0 proto kernel scope link src 192.168.92.3
Here’s there a relevant line related to the VM’s IP route:
192.168.92.0/24 dev enp0s8 proto kernel scope link src 192.168.92.2