diff --git a/pihole/docker-compose.yml b/pihole/docker-compose.yml index 31648bb..2c51a3d 100644 --- a/pihole/docker-compose.yml +++ b/pihole/docker-compose.yml @@ -1,24 +1,39 @@ -version: "3" +# pihole +# https://blog.ivansmirnov.name/set-up-pihole-using-docker-macvlan-network/ + +version: '2' -# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/ services: pihole: - container_name: pihole - image: pihole/pihole:latest - ports: - - "53:53/tcp" - - "53:53/udp" - - "67:67/udp" - - "80:80/tcp" - environment: - TZ: 'Europe/London' - WEBPASSWORD: '2twN2nwWyvEEm2L' - # Volumes store your data between container upgrades - volumes: - - './etc-pihole/:/etc/pihole/' - - './etc-dnsmasq.d/:/etc/dnsmasq.d/' - # Recommended but not required (DHCP needs NET_ADMIN) - # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities + container_name: pihole-vlan + image: pihole/pihole:2021.10.1 # check the latest version on docker hub. + hostname: pihole # set an easy hostname to remember + domainname: local # your local domain name + mac_address: de:ad:be:ef:ff:01 # can change or leave this cap_add: - NET_ADMIN - restart: unless-stopped \ No newline at end of file + networks: + macvlan0: # same as network specified below + ipv4_address: 192.168.1.59 # the IP of the pihole container + dns: + - 127.0.0.1 # use local DNS, since the pihole + - 1.1.1.1 # optional fallback DNS + ports: # expose all pihole ports. + - 443/tcp + - 53/tcp + - 53/udp + - 67/udp + - 80/tcp + volumes: # mount our data volumes. + - './etc-pihole/:/etc/pihole/' + - './etc-dnsmasq.d/:/etc/dnsmasq.d/' + environment: # set variables for pihole configuration. + ServerIP: 192.168.1.59 # must match ipv4_address above + VIRTUAL_HOST: pihole.local # Must be hostname + domainname from above + WEBPASSWORD: "" + TZ: 'Europe/London' # pick your timezone + restart: unless-stopped + +networks: + macvlan0: # externally created network (later in article) + external: true diff --git a/pihole/pi-vlan.service b/pihole/pi-vlan.service new file mode 100644 index 0000000..f71658f --- /dev/null +++ b/pihole/pi-vlan.service @@ -0,0 +1,8 @@ +[Unit] +After=network.target + +[Service] +ExecStart=/usr/local/bin/pi-vlan.sh + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/pihole/pi-vlan.sh b/pihole/pi-vlan.sh new file mode 100644 index 0000000..a2c807f --- /dev/null +++ b/pihole/pi-vlan.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +ip link add macvlan-shim link eth0 type macvlan mode bridge +ip addr add 192.168.1.60/28 dev macvlan-shim +ip link set macvlan-shim up +ifconfig macvlan-shim \ No newline at end of file diff --git a/pihole/readme.md b/pihole/readme.md index 1ac9165..108d52b 100644 --- a/pihole/readme.md +++ b/pihole/readme.md @@ -1,3 +1,42 @@ # Pi Hole -Text +## Create docker network +``` +docker network create -d macvlan \ + --subnet=192.168.1.10/24 --gateway=192.168.1.1 \ + --ip-range 192.168.1.59/28 \ + -o parent=eth0 \ + --aux-address="myserver=192.168.1.60" \ + macvlan0 +``` +then + +1. sudo ip link set eth0 promisc on +1. sudo ip link add macvlan-shim link eth0 type macvlan mode bridge +1. sudo ip addr add 192.168.1.60/28 dev macvlan-shim +1. sudo ip link set macvlan-shim up + +Check + ifconfig macvlan-shim + +## /usr/local/bin/pi-vlan.sh + +``` +#!/usr/bin/env bash +ip link add macvlan-shim link eth0 type macvlan mode bridge +ip addr add 192.168.1.60/28 dev macvlan-shim +ip link set macvlan-shim up +ifconfig macvlan-shim +``` +## /etc/systemd/system/pi-vlan.service + +``` +[Unit] +After=network.target + +[Service] +ExecStart=/usr/local/bin/pi-vlan.sh + +[Install] +WantedBy=default.target +```