├── .gitignore ├── Dockerfile ├── Makefile ├── README.md └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.tar 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM monstrenyatko/mdns-repeater 2 | 3 | COPY run.sh /app/ 4 | RUN chmod +x /app/run.sh 5 | 6 | ENTRYPOINT ["/app/run.sh"] 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | container_name := mdns-repeater 2 | repo_name := mag1024/mikrotik-docker-mdns-repeater 3 | 4 | default: container/arm64 5 | all: container/arm64 container/arm-v6 6 | clean: 7 | rm -f *.tar 8 | 9 | container/%: 10 | docker buildx build --load --platform linux/$(subst -,/,$*) -t $(container_name) . 11 | docker save $(container_name) -o $(container_name)-$*.tar 12 | 13 | push: 14 | docker buildx build --platform linux/arm64,linux/arm/v6 --push github.com/$(repo_name) -t $(repo_name):latest 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | As of RouterOS 7.16, Mikrotik now has a built-in mDNS repeater implementation: e.g. 3 | `/ip/dns/set mdns-repeat-ifaces=bridge,vlan-iot` 4 | 5 | # docker-mdns-repeater-mikrotik 6 | An mDNS repeater that can run as a container on Mikrotik routers. 7 | 8 | Based on: 9 | * [geekman/mdns-repeater](https://github.com/geekman/mdns-repeater) 10 | * [monstrenyatko/docker-mdns-repeater](https://github.com/monstrenyatko/docker-mdns-repeater) 11 | * [TheMickeyMike/docker-mdns-repeater-mikrotik](https://github.com/TheMickeyMike/docker-mdns-repeater-mikrotik) 12 | 13 | Images availabe on Dockerhub at [mag1024/mikrotik-docker-mdns-repeater](https://hub.docker.com/repository/docker/mag1024/mikrotik-docker-mdns-repeater). 14 | 15 | ## How it works 16 | As of Oct 2022, the Mikrotik container implementation is limited to exactly one 17 | network interface. There is no option for an equivalent of 'host' mode 18 | networking, and the interface must be of type veth, so we have to get creative 19 | to get a functional repeater. The key is to attach the veth to a trunk bridge 20 | that contains multiple vlans corresponding to the networks we want to repeat 21 | across, and then create interfaces for each of the vlans inside the container, 22 | using the veth as the parent. The set of vlans/interfaces to use is specified 23 | via the _REPEATER_INTERFACES_ env variable, and the container runs a dhcp client 24 | to obtain an IP for each of them. 25 | 26 | ## Setup 27 | Begin by following the [Mikrotik container 28 | documentation](https://help.mikrotik.com/docs/display/ROS/Container) to create 29 | the veth interface. Instead of creating a separate docker bridge, assign the 30 | new interface as a 'tagged' port to the bridge containing the interfaces you 31 | wish to repeat across. These interfaces can be vlan interfaces, or physical 32 | interfaces with pvid set -- depending on whether you use vlans for the rest of 33 | your network setup. Refer to the [Mikrotik bridge 34 | documentation](https://help.mikrotik.com/docs/display/ROS/Bridge+VLAN+Table) for 35 | more details. 36 | 37 | The following example uses _veth-trunk_ veth interface and _br-trunk_ bridge, 38 | configured with vlans 10, 11, 12. 39 | 40 | Note: The address here does not matter, but it must have one to make the 41 | interface 'active'. 42 | ``` 43 | /interface/veth/print 44 | Flags: X - disabled; R - running 45 | 0 R name="veth-trunk" address=10.200.200.200/24 gateway=10.200.200.1 46 | ``` 47 | 48 | Note: Again, pvid of the _veth_ itself does not matter. 49 | ``` 50 | /interface/bridge/port/print 51 | Flags: I - INACTIVE; H - HW-OFFLOAD 52 | Columns: INTERFACE, BRIDGE, HW, PVID, PRIORITY, PATH-COST, INTERNAL-PATH-COST, HORIZON 53 | # INTERFACE BRIDGE HW PVID PRIORITY PATH-COST INTERNAL-PATH-COST HORIZON 54 | 0 H ether2 br-trunk yes 10 0x80 10 10 none 55 | 1 H ether3 br-trunk yes 13 0x80 10 10 none 56 | ... 57 | 8 veth-trunk br-trunk 111 0x80 10 10 none 58 | ``` 59 | 60 | Note: The name of the interface inside the container is always _eth0_. 61 | ``` 62 | /container/envs/print 63 | 0 name="repeater_envs" key="REPEATER_INTERFACES" value="eth0.10 eth0.11 eth0.12" 64 | ``` 65 | 66 | Note: you may have to set the registry first via `/container/config/set registry-url=https://registry-1.docker.io`. 67 | Note: `start-on-boot` is only available on Mikrotik 7.6+ 68 | ``` 69 | /container/print 70 | 0 ... tag="mag1024/mikrotik-docker-mdns-repeater:latest" os="linux" 71 | arch="arm64" interface=veth-trunk envlist="repeater_envs" mounts="" dns="" hostname="mdns-repeater" logging=yes 72 | start-on-boot=yes status=running 73 | ``` 74 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit on error 4 | set -e 5 | 6 | MTU=$(ip link show "${REPEATER_INTERFACES%%[ .]*}" | awk '{print $5}') 7 | 8 | for IFNAME in $REPEATER_INTERFACES; do 9 | # INTERFACE PROVISION 10 | [ ! -d "/sys/class/net/$IFNAME" ] && { 11 | echo "create interface $IFNAME" 12 | ip link add link "${IFNAME%%.*}" \ 13 | name "$IFNAME" mtu "$MTU" type vlan id "${IFNAME##*.}" 14 | } 15 | echo "bring up $IFNAME interface" 16 | ip link set "$IFNAME" up 17 | 18 | # DHCP 19 | [ -f "/var/run/udhcpc.$IFNAME.pid" ] && { 20 | kill "$(cat "/var/run/udhcpc.$IFNAME.pid")" || true 21 | rm "/var/run/udhcpc.$IFNAME.pid" 22 | } 23 | echo "starting dhcp client on $IFNAME" 24 | udhcpc -b -i "$IFNAME" -x hostname:"$(hostname)" -p "/var/run/udhcpc.$IFNAME.pid" 25 | done 26 | 27 | exec /bin/mdns-repeater -f $REPEATER_INTERFACES 28 | --------------------------------------------------------------------------------