[add] support files
This commit is contained in:
		
							parent
							
								
									7c5c0b242e
								
							
						
					
					
						commit
						075b9fca9e
					
				
					 4 changed files with 87 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
    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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								pihole/pi-vlan.service
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								pihole/pi-vlan.service
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
[Unit]
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
ExecStart=/usr/local/bin/pi-vlan.sh
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=default.target
 | 
			
		||||
							
								
								
									
										5
									
								
								pihole/pi-vlan.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								pihole/pi-vlan.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
```
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue