• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a lightweight and performant multicast DNS (mDNS) reflector with modern design, supports zone based reflection and IPv6

mDNS Reflector

mDNS Reflector (mdns-reflector) is a lightweight and performant multicast DNS (mDNS) reflector with a modern design. It reflects mDNS queries and responses among multiple LANs, which allows you to run untrusted IoT devices in a separate LAN but those devices can still be discovered in other LANs.

Highlights

  • Low footprint, no dynamic memory allocation during reflecting
  • Rootless - can be run as either root or non-root
  • Supports zone based reflection
  • Supports both IPv4 and IPv6
  • Leverages epoll on Linux and kqueue on BSD and macOS

It provides a command line interface (CLI) familiar to the discontinued mdns-repeater.


Installation of mDNS Reflector using prebuilt binaries

Docker

docker pull yuxzhu/mdns-reflector:latest

Podman

podman pull yuxzhu/mdns-reflector:latest

Fedora / CentOS 8 / CentOS Stream 8

dnf copr enable -y yux/networking
dnf install -y mdns-reflector

CentOS 7

curl -fLo /etc/yum.repos.d/yux-networking-epel-7.repo  https://copr.fedorainfracloud.org/coprs/yux/networking/repo/epel-7/yux-networking-epel-7.repo
yum install -y mdns-reflector

Debian / Ubuntu

Available in Debian 'experimental' branch:

It can happen that the version in experimental is outdated. In that case experienced users can either build the .deb package themselves

OpenWRT

Coming soon.


Installing mDNS Reflector from Source

git clone https://github.com/vfreex/mdns-reflector
cd mdns-reflector && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make install

Usage

mdns-reflector is easy to use. Just run the following command on a multi-homed host:

mdns-reflector -fn eth0 eth1

where eth0 and eth1 are the interfaces that you want to reflect mDNS for.

Run mdns-reflector -h for help.

Similarly, run with Docker in the foreground:

docker run --net=host yuxzhu/mdns-reflector:latest mdns-reflector -fn eth0 eth1

Or run with Docker as a daemon:

docker run -d --restart=always --net=host yuxzhu/mdns-reflector:latest mdns-reflector -fn eth0 eth1

Systemd service

You can enable the systemd service with:

systemctl enable --now mdns-reflector

The main configuration file for the service daemon is located at: /etc/mdns-reflector/mdns-reflector.conf

Although you can add files to /etc/mdns-reflector/conf.d/ to overwrite the main configuration file.

Quick Tip: Adding a number and an underscore like 10_ as a prefix to your filename is good practice and ensures a predictable priority of the config files. 99_* files have a higher priority than 00_* files which means that the settings in file 20_example.conf would overwrite settings from 10_example.conf.

Multiple systemd services

mDNS Reflector supports multiple services running in parallel. You can archieve this by creating files like /etc/mdns-reflector/%i.conf.

Now enable the systemd service with this specific config file:

systemctl enable --now mdns-reflector@$(systemd-escape "%i")

NOTE: Replace %i with your config filename without the .conf at the end. The .conf filename suffix is still necessary though.

Important information about multiple services running in parallel

Let us define a few networks to make an example frame <iface_name>: <network_name>:

  • eth_home: Homenetwork
  • eth_smart: Smarthome-Devices
  • eth_print: Printers

We want the devices in Printers to announce their services into the Homenetwork. Likewise the devices in Smarthome-Devices should also announce their services into the Homenetwork.

mDNS Reflector does not support an interface occuring in more than one reflection planes. For example:

mdns-reflector eth_home eth_smart -- eth_home eth_print # Wrong!

At the moment this is only possible if multiple mDNS Reflector services are running in parallel.

Uni-directional service announcement is not supported at the moment but is planned.

So, for this example you'll need two config files.

/etc/mdns-reflector/smarthomestuff.conf:

INTERFACES=eth_home eth_smart
More stuff...

/etc/mdns-reflector/printerstuff.conf:

INTERFACES=eth_home eth_print
More stuff...

Enabling the service of course:

systemctl enable --now mdns-reflector@$(systemd-escape "smarthomestuff")
systemctl enable --now mdns-reflector@$(systemd-escape "printerstuff")

This would make all mDNS services visible in Homenetwork. But beware this also makes all services from devices withing the Homenetwork visible to the Smarthome-Devices and Printers networks.

Services within the Smarthome-Devices network won't be announced to the Printers network and vice-versa.


License

Copyright (C) 2021-2023 Yuxiang Zhu [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

More Repositories

1

hijackfilter

a set of free software to protect you from Internet hijacking
C
191
star
2

gones

Yet Another NES Emulator Written in Go
Go
123
star
3

docker-cowrie

Dockerfile and docker-compose file to run Cowrie in Docker.
30
star
4

docker-netease-cloud-music

Docker image of Netease Cloud Music (网易云音乐) for Linux.
Shell
26
star
5

kube-nextcloud

Containerized Nextcloud tailored for Kubernetes / OpenShift
Dockerfile
19
star
6

procslink

ProcsLink provides API for cross-namespace inter-process communication (IPC) over netlink socket.
Python
7
star
7

vimrc

Vimrc for Programmers using Vundle as plugin manager.
Vim Script
6
star
8

rime-zhengma

Zhengma support for RIME IME
5
star
9

ddns6

DDNS6 - One dynamic DNS client for multiple hosts
Rust
5
star
10

dockernet

With Dockernet, you can add custom interfaces, configure static IP addresses, and adding static routes to a Linux container in a simple way.
Shell
5
star
11

release-apiserver

Go
2
star
12

teamtalk-cloud

experimental cloud-native TeamTalk distribution
TSQL
2
star
13

performance-ci

This Jenkins plugin allows to run Apache Jmeter performance testing tool and monitor hardware resource of target servers using Jenkins. It can also generate various kinds of performance testing reports using perfcharts (https://github.com/vfreex/perfcharts) for performance analysis.
JavaScript
2
star
14

pyatfork

PyAtfork provides API to register fork handlers. PyAtfork is a wrapper for the POSIX Pthreads API pthread_atfork(3). I wrote this module because Python's ctypes library cannot handle this function correctly.
C
2
star
15

docker-spigot

Docker container image of Spigot Minecraft server
1
star
16

docker-spongevanilla

Shell
1
star