mDNS
Multicast DNS (mDNS) is an alternative to traditional DNS for LAN-local name resolution. DNS queries are sent by multicast, and the node with the name being queried responds.
On linux, avahi
is responsible for mDNS. avahi-daemon
runs by default on some(?) distros, responding to queries for <hostname>.local
.
You can start more instances to respond to requests for other hostnames too:
IFACE="eth0"
ADDR=$(ip addr list $IFACE | awk '/inet / {print $2}' | cut -d/ -f 1)
function _term {
pkill -P $$
}
trap _term SIGTERM
avahi-publish --address -R $NAME1.local $ADDR &
avahi-publish --address -R $NAME2.local $ADDR &
avahi-publish --address -R $NAME3.local $ADDR &
avahi-publish --address -R $NAME4.local $ADDR &
wait