# AdGuard on macvlan

**URL:** <https://forum.hhf.technology/t/adguard-on-macvlan/358>\
**Category:** Self-hosted Applications\
**Tags:** docker-compose, docker-networking, macvlan, adguard\
**Created:** [November 5, 2024, 2:17pm UTC](https://forum.hhf.technology/t/adguard-on-macvlan/358 "2024-11-05T14:17:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [November 5, 2024, 2:17pm UTC](https://forum.hhf.technology/t/adguard-on-macvlan/358/1 "2024-11-05T14:17:54Z")

</div>

```yaml
version: "3"
services:
  adguard:
    image: adguard/adguardhome:latest
    container_name: adguard
    volumes:
      - /volume1/docker/adguard/config:/opt/adguardhome/conf
      - /volume1/docker/adguard/data:/opt/adguardhome/work/data
    restart: always
    networks:
      macvlan-host:
        ipv4_address: 192.168.178.2 # change it to your internal IPv4 exisitng network
        ipv6_address: xxxx:xxxx:xxxx:xxxx::2 # fixed external IPv6/64 prefix + your own private /64 identifier
      macvlan-bridge:
        ipv4_address: 172.16.0.2 # randon private ipv4 address which is not in the same segment as above
        ipv6_address: xxxx:xxxx:xxxx:xxxx::2 # random ipv6 address which has not the same prefix as above

networks:
  macvlan-host:
    name: macvlan-host
    enable_ipv6: true
    driver: macvlan
    driver_opts:
     parent: eth0
    ipam:
     config:
      - subnet: "192.168.178.0/16" # paste in your existing private subnet address (look on your router)
        gateway: "192.168.178.1" # paste in your existing private gateway address (look on your router)
        ip_range: "192.168.178.2/32" # the ip range for addresses for this macvlan. Past in your choosen address from 12 (/32 means only one to use)
      - subnet: "xxxx:xxxx:xxxx:xxxx::/64" # paste in your existing private ipv6 subnet address (look on your router)
        gateway: "xxxx:xxxx:xxxx:xxxx::1" # paste in your existing private ipv6 gateway address (look on your router)
        ip_range: "xxxx:xxxx:xxxx:xxxx::2/128" # the ip range for ipv6 addresses for this macvlan. Past in your choosen address from 13 (/128 means only one to use)
        
  macvlan-bridge:
    name: macvlan-bridge
    enable_ipv6: true
    driver: bridge
    ipam:
     config:
      - subnet: "172.16.0.0/24" # paste in a random private subnet address
        gateway: "172.16.0.1" # paste in a random private gateway address
        ip_range: "172.16.0.2/32" # the ip range for addresses for this bridge. Paste in your choosen address from 15 (/32 means only one to use)
      - subnet: "xxxx:xxxx:xxxx:xxxx::/64" # paste in a random private ipv6 subnet address
        gateway: "xxxx:xxxx:xxxx:xxxx::1" # paste in a random private ipv6 gateway address
        ip_range: "xxxx:xxxx:xxxx:xxxx::2/128" # the ip range for ipv6 addresses for this bridge. Past in your choosen address from 16 (/128 means only one to use)

```

---

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [November 7, 2024, 11:50am UTC](https://forum.hhf.technology/t/adguard-on-macvlan/358/2 "2024-11-07T11:50:46Z")

</div>

how to specify both IPv6 and IPv4 addresses for one container

```yaml
services:
  coredns:
    image: coredns/coredns
    container_name: coredns
    command: -conf /data/Corefile
    ports:
      - 53:53/udp
      - 53:53/tcp
      - 9153:9153/tcp
    volumes:
      - ./coredns:/data:ro
    networks:
      sapling:
        ipv4_address: 172.16.238.5
        ipv6_address: 2404:xxxx:4314:d::5
    restart: unless-stopped

networks:
  sapling:
    driver: bridge
    driver_opts:
      com.docker.network.bridge.gateway_mode_ipv6: "routed"
    enable_ipv6: true
    ipam:
      driver: default
      config:
        - subnet: 172.16.238.0/24
          gateway: 172.16.238.1
        - subnet: 2404:xxxx:4314:d::/64
          gateway: 2404:xxxx:4314:d::1

```
