Skip to content

Instantly share code, notes, and snippets.

@xirixiz
Last active September 6, 2025 08:26
Show Gist options
  • Save xirixiz/ecad37bac9a07c2a1204ab4f9a17db3c to your computer and use it in GitHub Desktop.
Save xirixiz/ecad37bac9a07c2a1204ab4f9a17db3c to your computer and use it in GitHub Desktop.

Revisions

  1. Bram van Dartel revised this gist Feb 3, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ macvlan0 Link encap:Ethernet HWaddr 92:8D:43:0E:E2:D8
    RX bytes:34863 (34.0 KiB) TX bytes:16322 (15.9 KiB)

    # Create a macvlan Docker network using eth0
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 -o parent=eth0 macvlan
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 --ip-range=192.168.1.210/28 -o parent=eth0 macvlan

    # It's also possible to create a scheduled task at startup as the root user, it's wise to append the following in front of the above commands
    while ! ip link show eth0 | grep -q 'state UP'; do
  2. Bram van Dartel revised this gist Apr 18, 2020. 1 changed file with 21 additions and 3 deletions.
    24 changes: 21 additions & 3 deletions pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,18 @@ ip addr add 192.168.1.210/28 dev macvlan0
    # Bring up the macvlan0 adapter
    ip link set macvlan0 up

    # Check virtual adapter status with ifconfig
    ifconfig
    # Output should be something like this:
    macvlan0 Link encap:Ethernet HWaddr 92:8D:43:0E:E2:D8
    inet addr:192.168.1.210 Bcast:0.0.0.0 Mask:255.255.255.240
    inet6 addr: fe80::908d:43ff:fe0e:e2d8/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:79 errors:0 dropped:0 overruns:0 frame:0
    TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1
    RX bytes:34863 (34.0 KiB) TX bytes:16322 (15.9 KiB)

    # Create a macvlan Docker network using eth0
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 -o parent=eth0 macvlan

    @@ -23,9 +35,10 @@ while ! ip link show eth0 | grep -q 'state UP'; do
    done

    # Perform a basic test with NGINX
    docker run --net=macvlan -dit --name nginx-test-01 --ip=192.168.1.211 -p 8080:80 nginx:alpine nginx-debug -g 'daemon off;'
    docker run --net=macvlan -dit --name nginx-test-01 --ip=192.168.1.211 nginx:alpine nginx-debug -g 'daemon off;'

    # Browse to http://192.168.1.211 in your local network, you should see the nginx welcome page! ...Don't forget to remove the container afterwards...
    docker rm nginx-test-01 --force

    # Now start PiHole on a macvlan enabled IP address f.e.
    # Also I've added a fake mac address so the container always uses the samen mac, handy to make a reservation in your DHCP scope or do whatever you like to do with it.
    @@ -51,5 +64,10 @@ docker run --detach \
    --ip "192.168.1.212" \
    --mac-address "02:42:c0:a8:01:d7" \
    ${IMAGE}

    # Happy days!

    # Cleanup macvlan
    ip link set macvlan0 down
    ip link delete macvlan0
    docker network rm macvlan

    # Happy days!
  3. Bram van Dartel revised this gist Apr 18, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ done
    # Perform a basic test with NGINX
    docker run --net=macvlan -dit --name nginx-test-01 --ip=192.168.1.211 -p 8080:80 nginx:alpine nginx-debug -g 'daemon off;'

    # Browse to http://192.168.1.210 in your local network, you should see the nginx welcome page! ...Don't forget to remove the container afterwards...
    # Browse to http://192.168.1.211 in your local network, you should see the nginx welcome page! ...Don't forget to remove the container afterwards...

    # Now start PiHole on a macvlan enabled IP address f.e.
    # Also I've added a fake mac address so the container always uses the samen mac, handy to make a reservation in your DHCP scope or do whatever you like to do with it.
  4. Bram van Dartel revised this gist Apr 18, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ docker run --detach \
    --dns=1.1.1.1 \
    --env "DNS1=1.1.1.1" \
    --env "DNS2=1.0.0.1" \
    --env "ServerIP=192.168.1.210" \
    --env "ServerIP=192.168.1.212" \
    --env "DNSMASQ_LISTENING=all" \
    --env "WEBPASSWORD=<secret>" \
    --env "TZ=Europe/Amsterdam" \
  5. Bram van Dartel revised this gist Apr 18, 2020. 1 changed file with 14 additions and 12 deletions.
    26 changes: 14 additions & 12 deletions pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,29 @@
    #!/bin/bash

    # NAS IP: 192.168.1.10 in this example
    # DHCP scope reservation for macvlan: 192.168.1.208/28 (Details below)
    ## Network: 192.168.1.208/28 11000000.10101000.00000001.1101 0000 (Class C)
    ## HostMin: 192.168.1.209 11000000.10101000.00000001.1101 0001
    ## HostMax: 192.168.1.222 11000000.10101000.00000001.1101 1110
    ## Hosts/Net: 14 (Private Internet)

    # Create a macvlan Docker network using eth0
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.10/24 -o parent=eth0 macvlan
    # DHCP scope reservation for macvlan: 192.168.1.210/28 (Details below)
    ## Network: 192.168.1.210/28
    ## HostMin: 192.168.1.211
    ## HostMax: 192.168.1.224
    ## Hosts/Net: 14

    # Create a Synology macvlan0 bridge network attached to the physical eth0, and add the ip range scope (sudo)
    ip link add macvlan0 link eth0 type macvlan mode bridge
    ip addr add 192.168.1.208/28 dev macvlan0
    ifconfig macvlan0 up
    # Specify part of the eth0 scope you'd like to reserve for macvlan0
    ip addr add 192.168.1.210/28 dev macvlan0
    # Bring up the macvlan0 adapter
    ip link set macvlan0 up

    # Create a macvlan Docker network using eth0
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 -o parent=eth0 macvlan

    # It's also possible to create a scheduled task at startup as the root user, it's wise to append the following in front of the above commands
    while ! ip link show eth0 | grep -q 'state UP'; do
    sleep 1
    done

    # Perform a basic test with NGINX
    docker run --net=macvlan -d --ip=192.168.1.210 -p 80:80 nginx
    docker run --net=macvlan -dit --name nginx-test-01 --ip=192.168.1.211 -p 8080:80 nginx:alpine nginx-debug -g 'daemon off;'

    # Browse to http://192.168.1.210 in your local network, you should see the nginx welcome page! ...Don't forget to remove the container afterwards...

    @@ -46,7 +48,7 @@ docker run --detach \
    --env "WEBPASSWORD=<secret>" \
    --env "TZ=Europe/Amsterdam" \
    --network macvlan \
    --ip "192.168.1.210" \
    --ip "192.168.1.212" \
    --mac-address "02:42:c0:a8:01:d7" \
    ${IMAGE}

  6. Bram van Dartel revised this gist Oct 3, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,13 @@ while ! ip link show eth0 | grep -q 'state UP'; do
    sleep 1
    done

    # Perform a basic test with NGINX
    docker run --net=macvlan -d --ip=192.168.1.210 -p 80:80 nginx

    # Browse to http://192.168.1.210 in your local network, you should see the nginx welcome page! ...Don't forget to remove the container afterwards...

    # Now start PiHole on a macvlan enabled IP address f.e.
    # Also I've added a fake mac address so the container always uses the samen mac, handy to make a reservation in your DHCP scope or do whatever you like to do with it.
    DOCKERHOME=<some path>
    NAME=pihole-macvlan
    IMAGE=pihole/pihole
  7. Bram van Dartel created this gist Oct 3, 2019.
    47 changes: 47 additions & 0 deletions pihole-macvlan-synology-docker.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/bin/bash

    # NAS IP: 192.168.1.10 in this example
    # DHCP scope reservation for macvlan: 192.168.1.208/28 (Details below)
    ## Network: 192.168.1.208/28 11000000.10101000.00000001.1101 0000 (Class C)
    ## HostMin: 192.168.1.209 11000000.10101000.00000001.1101 0001
    ## HostMax: 192.168.1.222 11000000.10101000.00000001.1101 1110
    ## Hosts/Net: 14 (Private Internet)

    # Create a macvlan Docker network using eth0
    docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.10/24 -o parent=eth0 macvlan

    # Create a Synology macvlan0 bridge network attached to the physical eth0, and add the ip range scope (sudo)
    ip link add macvlan0 link eth0 type macvlan mode bridge
    ip addr add 192.168.1.208/28 dev macvlan0
    ifconfig macvlan0 up

    # It's also possible to create a scheduled task at startup as the root user, it's wise to append the following in front of the above commands
    while ! ip link show eth0 | grep -q 'state UP'; do
    sleep 1
    done

    # Now start PiHole on a macvlan enabled IP address f.e.
    DOCKERHOME=<some path>
    NAME=pihole-macvlan
    IMAGE=pihole/pihole
    docker run --detach \
    --name ${NAME} \
    --restart always \
    --volume /etc/localtime:/etc/localtime:ro \
    --volume ${DOCKERHOME}/data/${NAME}/config:/etc/pihole \
    --volume ${DOCKERHOME}/data/${NAME}/dnsmasq.d:/etc/dnsmasq.d \
    --cap-add NET_ADMIN \
    --dns=127.0.0.1 \
    --dns=1.1.1.1 \
    --env "DNS1=1.1.1.1" \
    --env "DNS2=1.0.0.1" \
    --env "ServerIP=192.168.1.210" \
    --env "DNSMASQ_LISTENING=all" \
    --env "WEBPASSWORD=<secret>" \
    --env "TZ=Europe/Amsterdam" \
    --network macvlan \
    --ip "192.168.1.210" \
    --mac-address "02:42:c0:a8:01:d7" \
    ${IMAGE}

    # Happy days!